Skip to content

Commit

Permalink
feat: support multiple bitrate values in stream proxy filter
Browse files Browse the repository at this point in the history
Updated the stream proxy filter to parse both individual bitrate values and arrays of bitrate values for filtering.

- Modified the input type `br` in the filter function to accept:
  - `number`: Individual bitrate values.
  - `number[]`: Arrays of bitrate values.
  - `"*"`: A wildcard to match any bitrate.

This enhancement allows more flexible filtering based on bitrate specifications.
  • Loading branch information
edvinhed committed Jul 2, 2024
1 parent 1a1fea7 commit 31a9f15
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Delay Corruption:
sq?: number | "*", // media sequence number of target segment in playlist. If "*", then target all segments
rsq?: number, // relative sequence number from where a livestream is currently at
ms?: number, // time to delay in milliseconds
br?: number | "*", // apply only to specific bitrate
br?: number | number[] | "*", // apply only to specific or an array of specific bitrates
}
```

Expand All @@ -133,7 +133,7 @@ Status Code Corruption:
sq?: number | "*", // media sequence number of target segment in playlist. If "*", then target all segments
rsq?: number, // relative sequence number from where a livestream is currently at
code?: number, // code to return in http response status header instead of media file
br?: number | "*", // apply only to specific bitrate
br?: number | number[] | "*", // apply only to specific or an array of specific bitrates
}
```

Expand All @@ -144,7 +144,7 @@ Timeout Corruption:
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
rsq?: number, // relative sequence number from where a livestream is currently at
br?: number | "*", // apply only to specific bitrate
br?: number | number[] | "*", // apply only to specific or an array of specific bitrates
}
```

Expand All @@ -155,7 +155,7 @@ Throttle Corruption:
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
rsq?: number, // relative sequence number from where a livestream is currently at
br?: number | "*", // apply only to specific bitrate
br?: number | number[] | "*", // apply only to specific or an array of specific bitrates
rate?: number // rate in bytes per second to limit the segment download speed to
}
```
Expand Down Expand Up @@ -204,14 +204,19 @@ https://<chaos-proxy>/api/v2/manifests/hls/proxy-master.m3u8?url=https://maitv-v
https://<chaos-proxy>/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. VOD: With segment delay of 1500ms on sixth segment, followed by a response code 400 if the bitrate is 1212000 OR 3131000:

7. LIVE: With response of status code 404 on segment with sequence number 105:
```
https://<chaos-proxy>/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:[1212000,3131000]}]
```

8. LIVE: With response of status code 404 on segment with sequence number 105:

```
https://<chaos-proxy>/api/v2/manifests/hls/proxy-master.m3u8?url=https://demo.vc.eyevinn.technology/channels/demo/master.m3u8&statusCode=[{sq:105,code:400}]
```

8. LIVE: Delay response of media manifest ladder 1 and 2 with 500 ms
9. LIVE: Delay response of media manifest ladder 1 and 2 with 500 ms

```
https://<chaos-proxy>/api/v2/manifests/hls/proxy-master.m3u8?url=https://demo.vc.eyevinn.technology/channels/demo/master.m3u8&delay=[{l:1,ms:500},{l:2,ms:500}]
Expand Down
2 changes: 1 addition & 1 deletion src/manifests/utils/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export const corruptorConfigUtils = function (
// If bitrate is set, filter out segments that doesn't match
params = params.filter(
(config) =>
!config?.br || config?.br === '*' || config?.br === segmentBitrate
!config?.br || config?.br === '*' || (config?.br.toString().includes(segmentBitrate.toString())) //Checks if .br contains bitrates that need to be filtered

Check failure on line 184 in src/manifests/utils/configs.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `·config?.br·===·'*'·||·(config?.br.toString().includes(segmentBitrate.toString()))·` with `⏎··············config?.br·===·'*'·||⏎··············config?.br.toString().includes(segmentBitrate.toString())`
);

// Replace relative sequence numbers with absolute ones
Expand Down

0 comments on commit 31a9f15

Please sign in to comment.