Skip to content

Commit

Permalink
Adding support for manifest text and file input (#639)
Browse files Browse the repository at this point in the history
* Added missing parameters

* Implemented sending mpd as text

* Deactivated text and file input for mpd

* Added latest xsd option

* Disabling incompatible modules when entering m3u8

* Enabled mpd file and text input

* clean up
  • Loading branch information
FritzHeiden authored Feb 27, 2023
1 parent 24d2196 commit 6b6b846
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 18 deletions.
1 change: 0 additions & 1 deletion Conformance-Frontend/lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const Net = (function () {
form.appendChild(postVariable);
}
document.body.appendChild(form);
console.log(new FormData(form));

form.submit();
}
Expand Down
21 changes: 18 additions & 3 deletions Conformance-Frontend/services/conformance-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,13 @@ const ConformanceService = (function () {
}

async function validateContentByText({ mpdText, activeModules }) {
console.log("validating");
mpdText = encodeURIComponent(mpdText);
let data = `mpd=${mpdText}&`;
modules.forEach((module) => {
if (!module.queryParam) return;
data =
data + `${module.queryParam}=${activeModules[module.id] ? "1" : "0"}&`;
});
console.log("requesting");
let results = await Net.sendRequest({
method: "POST",
uri: BASE_URI,
Expand All @@ -95,7 +93,23 @@ const ConformanceService = (function () {
},
});
results = JSON.parse(results);
console.log("got result", results);
results = convertInfoData(results);
return results;
}

async function validateContentByFile({ mpdFile, activeModules }) {
let data = new FormData();
data.append("mpd", mpdFile);
modules.forEach((module) => {
if (!module.queryParam) return;
data.append(module.queryParam, activeModules[module.id] ? "1" : "0");
});
let results = await Net.sendRequest({
method: "POST",
uri: BASE_URI,
data,
});
results = JSON.parse(results);
results = convertInfoData(results);
return results;
}
Expand Down Expand Up @@ -169,6 +183,7 @@ const ConformanceService = (function () {
let instance = {
validateContentByUrl,
validateContentByText,
validateContentByFile,
convertInfoData,
modules,
};
Expand Down
2 changes: 0 additions & 2 deletions Conformance-Frontend/src/tool-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ function ToolView() {
},
],
});
part.getTestResults().forEach((test) => console.log(test.getTestId()));
return moduleElement;
}

Expand Down Expand Up @@ -279,7 +278,6 @@ function ToolView() {
_resultDetailsId = elementId = elementId || _resultDetailsId;
let { module, part, section, test, type } = _state.detailSelect;
let resultDetails = null;
console.log(_state.detailSelect);

if (module && part && section && test) {
resultDetails = createTestResultDetailsElement(elementId);
Expand Down
46 changes: 34 additions & 12 deletions Conformance-Frontend/src/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function Validator({ modules }) {
break;
}
case TEXT_TYPE:
case FILE_TYPE:
break;
default:
return;
Expand Down Expand Up @@ -84,6 +85,18 @@ function Validator({ modules }) {
}
break;
}
case FILE_TYPE: {
let { mpdFile, activeModules } = _state;
try {
result = await ConformanceService.validateContentByFile({
mpdFile,
activeModules,
});
} catch (error) {
_state.error = error;
}
break;
}
}

setValidatorState(READY);
Expand All @@ -94,17 +107,17 @@ function Validator({ modules }) {
}

function setValidatorState(newState) {
if (newState === READY) {
if (
_state.activeMpdForm === TEXT_TYPE ||
_state.activeMpdForm === FILE_TYPE
) {
_state.validatorState = NOT_IMPLEMENTED;
} else {
_state.validatorState = READY;
}
return;
}
//if (newState === READY) {
// if (
// _state.activeMpdForm === TEXT_TYPE ||
// _state.activeMpdForm === FILE_TYPE
// ) {
// _state.validatorState = NOT_IMPLEMENTED;
// } else {
// _state.validatorState = READY;
// }
// return;
//}
_state.validatorState = newState;
}

Expand Down Expand Up @@ -231,7 +244,16 @@ function Validator({ modules }) {
className: "form-control",
id: "mpd-file",
onchange: (event) => {
_state.mpdFile = event.target.value;
var mpdFile = event.target.files[0];
_state.mpdFile = mpdFile;
var lastFourChars = mpdFile.name.substring(
mpdFile.name.length - 4
);
var m3u8Detected = lastFourChars === "m3u8";
if (m3u8Detected !== _state.m3u8Detected) {
_state.m3u8Detected = m3u8Detected;
render();
}
},
};
case "text":
Expand Down

0 comments on commit 6b6b846

Please sign in to comment.