Skip to content

Commit

Permalink
[v5] CommonMediaRequest (#4299)
Browse files Browse the repository at this point in the history
* Add @svta/common-media-library dependency

* Add MediaPlayer API to register/unregister request and response plugins

* Refacotr HTTPLoader to integrate CommonMediaLibrary Request and Response API

- use CommonMediaRequest and CommonMediaResponse as base types for processing requests and responses
- apply request and response plugins
- mutualize RequestModifier usage in HTTPLoader and apply RequestModifier before request plugins
- update CmsdModel since response headers are now returned as a record of key:value

* Add sample demo for RequestPlugin (in typescript)

* Fix @svta/common-media-library import

* Upgrade @svta/common-media-library to v0.4.5

* CommonMediaRequest:

- rename Request/ResponsePlugin to Request/ResponseInterceptor
- Request/ResponseInterceptor resolve Promise with returned request/response
- rename sample request-plugin to network-interceptor

* HTTPLoader: fix aborted requests metrics

* Update package-lock.json

* Update common-media-library version (0.5.0)

* Fix RequestModifier.modifyRequest returned promise

* Fix XHRLoader unit tests

* Fix HTTPLoader unit tests

- HTTLoader.load returned a Promise resolved once the inner loader (e.g. XHR) is loaded in order to get the XMLHttpRequest

* Fix HTTPLoader unit tests

- HTTLoader.load returned a Promise resolved once the inner loader (e.g. XHR) is loaded in order to get the XMLHttpRequest

* Update network-interceptor sample to use samples template

* XHRLoader/FetchLoader: add jsdoc for load() method

* FetchLoader: rename requestObj into fragmentRequest

* HTTPLoader: refactor request timing info completion

* HTTPLoader: clean and some refactor (reduce _handleLoaded() parameters)

* Add circleci command to build samples

* Add circleci command to build samples

* Update network-interceptor sample to include typescriopt source code

* Set request handlers (onload, onerror etc) in customData property

* Fix unit tests

* Remove RequestModifier

* Remove SegmentResponseModifier

* Remove SegmentResponseModifier

* Use Resource Timing info when available for CommonMediaResponse

* Complete HTTPLoader refactoring

* HTTPLoader: fix request/response info completion on timeout

* Fix BolaRule when abandoning segments (before any quality switch has been done)
  • Loading branch information
bbert committed Jan 8, 2024
1 parent 295c666 commit 262b536
Show file tree
Hide file tree
Showing 40 changed files with 3,509 additions and 743 deletions.
20 changes: 20 additions & 0 deletions .circleci/config.yml
Expand Up @@ -55,6 +55,7 @@ commands:
command: |
npm run build
npm run test
process_test_results: # CircleCI can not handle NaN values so we replace them with 0
steps:
- run:
Expand Down Expand Up @@ -97,13 +98,32 @@ commands:
name: Run functional tests (<<parameters.browser>> / <<parameters.protocol>>) <<parameters.groupname>>
command:
node test/functional/runTests.cjs --selenium=remote --reporters=junit --app=remote --browsers=<<parameters.browser>> --protocol=<<parameters.protocol>> --groupname="<<parameters.groupname>>"
build_samples:
# parameters:
# samples:
# default: "network-interceptor"
# type: string
steps:
- run:
name: Install dependencies and build samples
command: |
for sample in "${SAMPLES}"; do
echo "Build sample $sample"
cd samples/$sample
npm install
npm run build
done
jobs:
build-and-unit-test:
environment:
SAMPLES: "network-interceptor"
executor: dashjs-executor
steps:
- checkout
- dependencies_setup
- build_unit_test_steps
- build_samples

merge-build-and-unit-test:
executor: dashjs-executor
Expand Down
16 changes: 10 additions & 6 deletions index.d.ts
@@ -1,3 +1,5 @@
import * as CommonMediaLibrary from '@svta/common-media-library';

export = dashjs;
export as namespace dashjs;

Expand Down Expand Up @@ -1483,6 +1485,14 @@ declare namespace dashjs {

setProtectionData(value: ProtectionDataSet): void;

addRequestInterceptor(interceptor: CommonMediaLibrary.RequestInterceptor): void;

removeRequestInterceptor(interceptor: CommonMediaLibrary.RequestInterceptor): void;

addResponseInterceptor(interceptor: CommonMediaLibrary.ResponseInterceptor): void;

removeResponseInterceptor(interceptor: CommonMediaLibrary.ResponseInterceptor): void;

registerLicenseRequestFilter(filter: RequestFilter): void;

registerLicenseResponseFilter(filter: ResponseFilter): void;
Expand Down Expand Up @@ -3962,12 +3972,6 @@ declare namespace dashjs {
areEqual(obj1: object, obj2: object): boolean;
}

export interface RequestModifier {
modifyRequestURL(url: string): string;

modifyRequestHeader(request: Request): Request;
}

export interface SupervisorTools {
checkParameterType(parameter: any, type: string): void;

Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -58,7 +58,7 @@
"yargs": "16.0.3"
},
"dependencies": {
"@svta/common-media-library": "^0.4.5",
"@svta/common-media-library": "^0.5.0",
"bcp-47-match": "^2.0.3",
"bcp-47-normalize": "^2.3.0",
"codem-isoboxer": "0.3.9",
Expand Down
104 changes: 0 additions & 104 deletions samples/advanced/extend.html

This file was deleted.

83 changes: 0 additions & 83 deletions samples/advanced/modify-segment-response.html

This file was deleted.

0 comments on commit 262b536

Please sign in to comment.