Skip to content

Commit

Permalink
feat: add bitrate filter argument (#15)
Browse files Browse the repository at this point in the history
* refactor: convertToALBEvent

Use URLSearchParams instead of custom equivalent

* refactor: rename convertToALBEvent and fix types

* chore: add types for clone and xml2js

* refactor: dash manifest handler

* refactor: fix typo SEGEMTS->SEGMENTS in constants

* refactor: fix typo seglemt->segment

* refactor: fix typos parseable->parsable

* refactor: small improvements to dashManifestUtils.ts

Object.assign doesn't do deep clonings, so there's no point to use it
around just one object, and it's standard practice to use dot notation
over brackets for object properties.

* refactor: clean up dash/segment.ts

* refactor: statuscode.ts

* refactor: configs.ts

* refactor: change getManifestConfigs argument to typed json (record)

* refactor: clean up hls/master.ts

* chore: add comment about seemingly redundant method

* refactor: small improvments

* Avoid mutating input argument
* Avoid declaring type if it's inferred anyway
* Do decalre if it's not

* feat: add support for bitrate argument

* chore: add logging for when applying corruptions

* fix: use 302 redirection

301 redirection means permanently moved, but we want the browser to always go via the proxy if the same segment is requested again.

* chore: add myself to contributors list
  • Loading branch information
friday authored Nov 17, 2022
1 parent ded98d5 commit 4128195
Show file tree
Hide file tree
Showing 26 changed files with 1,492 additions and 421 deletions.
28 changes: 16 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ To try it out, go to your favourite HLS/MPEG-DASH video player such as `https://
| `/api/v2/manifests/hls/proxy-master.m3u8` | GET | Returns a proxy Multivariant M3U8 file, based on query parameters |
| `/api/v2/manifests/hls/proxy-media.m3u8` | GET | Returns a proxy Media M3U8 file, based on query parameters |
| `/api/v2/manifests/dash/proxy-master.mpd` | GET | Returns a proxy MPD file, based on query parameters |
| `/api/v2/manifests/dash/proxy-segment` | GET | Applies corruption present in query parameter and may return a 301 redirect to the original segment file |
| `/api/v2/segments/proxy-segment` | GET | Applies corruption present in query parameter and may return a 301 redirect to the original segment file |
| `/api/v2/manifests/dash/proxy-segment` | GET | Applies corruption present in query parameter and may return a 302 redirect to the original segment file |
| `/api/v2/segments/proxy-segment` | GET | Applies corruption present in query parameter and may return a 302 redirect to the original segment file |
| `/` | GET | Server health check |

### Query Parameters
Expand Down Expand Up @@ -66,28 +66,31 @@ Delay Corruption:

```typescript
{
i?: number | "*", // index of target segment in playlist. If "*", then target all segments. (Starts on 0 for HLS / 1 for MPEG-DASH)
sq?: number | "*",// media sequence number of target segment in playlist. If "*", then target all segments
ms?: number, // time to delay in milliseconds
i?: number | "*", // index of target segment in playlist. If "*", then target all segments. (Starts on 0 for HLS / 1 for MPEG-DASH)
sq?: number | "*", // media sequence number of target segment in playlist. If "*", then target all segments
ms?: number, // time to delay in milliseconds
br?: number | "*", // apply only to specific bitrate
}
```

Status Code Corruption:

```typescript
{
i?: number | "*", // index of target segment in playlist. If "*", then target all segments. (Starts on 0 for HLS / 1 for MPEG-DASH)
sq? number | "*", // media sequence number of target segment in playlist. If "*", then target all segments
code?: number, // code to return in http response status header instead of media file
i?: number | "*", // index of target segment in playlist. If "*", then target all segments. (Starts on 0 for HLS / 1 for MPEG-DASH)
sq?: number | "*", // media sequence number of target segment in playlist. If "*", then target all segments
code?: number, // code to return in http response status header instead of media file
br?: number | "*", // apply only to specific bitrate
}
```

Timeout Corruption:

```typescript
{
i?: number | "*", // index of target segment in playlist. If "*", then target all segments. (Starts on 0 for HLS / 1 for MPEG-DASH)
sq?: number | "*",// media sequence number of target segment in playlist. If "*", then target all segments
i?: number | "*", // index of target segment in playlist. If "*", then target all segments. (Starts on 0 for HLS / 1 for MPEG-DASH)
sq?: number | "*", // media sequence number of target segment in playlist. If "*", then target all segments
br?: number | "*", // apply only to specific bitrate
}
```

Expand Down Expand Up @@ -127,10 +130,11 @@ https://chaos-proxy.prod.eyevinn.technology/api/v2/manifests/hls/proxy-master.m3
https://chaos-proxy.prod.eyevinn.technology/api/v2/manifests/hls/proxy-master.m3u8?url=https://maitv-vod.lab.eyevinn.technology/VINN.mp4/master.m3u8&delay=[{i:4,ms:1500}]&statusCode=[{i:5,code:404}]&timeout=[{i:9}]
```

6. VOD: With segment delay of 1500ms and response code 400 on sixth (response of 400 will be sent after 1500ms):
6. VOD: With segment delay of 1500ms on sixth segment, followed by a response code 400 if the bitrate is 2426000:

```
https://chaos-proxy.prod.eyevinn.technology/api/v2/manifests/hls/proxy-master.m3u8?url=https://maitv-vod.lab.eyevinn.technology/VINN.mp4/master.m3u8&delay=[{i:5,ms:1500}]&statusCode=[{i:5,code:400}]
https://chaos-proxy.prod.eyevinn.technology/api/v2/manifests/hls/proxy-master.m3u8?url=https://maitv-vod.lab.eyevinn.technology/VINN.mp4/master.m3u8&delay=[{i:5,ms:1500}]&statusCode=[{i:5,code:400,br:2426000}]
```

7. LIVE: With response of status code 404 on segment with sequence number 105:
Expand Down
Loading

0 comments on commit 4128195

Please sign in to comment.