Skip to content

Commit

Permalink
Add try catch block to hook segment index method.
Browse files Browse the repository at this point in the history
  • Loading branch information
i-zolotarenko committed Dec 14, 2023
1 parent 0a0e424 commit 13ccdba
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
19 changes: 11 additions & 8 deletions p2p-media-loader-demo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,27 @@ const streamUrls = {
hlsBigBunnyBuck: "https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8",
hlsByteRangeVideo:
"https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8",
hlsBasicExample:
"https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8",
hlsAdvancedVideo:
"https://devstreaming-cdn.apple.com/videos/streaming/examples/adv_dv_atmos/main.m3u8",
hlsAdvancedVideo2:
"https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_adv_example_hevc/master.m3u8",
hlsAdvancedVideo3:
"https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/master.m3u8",
hlsAdvancedVideo4:
"https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8",
hlsBasicExample:
"https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8",
hlsLive1:
"https://fcc3ddae59ed.us-west-2.playback.live-video.net/api/video/v1/us-west-2.893648527354.channel.DmumNckWFTqz.m3u8",
hlsLive2:
"https://cph-p2p-msl.akamaized.net/hls/live/2000341/test/master.m3u8",
live2OnlyLevel4:
hlsLive2Level4Only:
"https://cph-p2p-msl.akamaized.net/hls/live/2000341/test/level_4.m3u8",
audioOnly:
hlsAudioOnly:
"https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/a1/prog_index.m3u8",
bigBunnyBuckDash: "https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd",
dashLiveBigBunnyBuck:
"https://livesim.dashif.org/livesim/testpic_2s/Manifest.mpd",
dashVODBigBunnyBuck:
"https://dash.akamaized.net/dash264/TestCases/5b/nomor/6.mpd",
dashLiveHokey:
"https://d24rwxnt7vw9qb.cloudfront.net/v1/dash/e6d234965645b411ad572802b6c9d5a10799c9c1/All_Reference_Streams/4577dca5f8a44756875ab5cc913cd1f1/index.mpd",
};

function App() {
Expand Down Expand Up @@ -302,6 +300,10 @@ function App() {
}
};

const createInNewTab = () => {
window.open(window.location.href, "_blank");
};

return (
<div style={{ width: 1000, margin: "auto" }}>
<div style={{ textAlign: "center" }}>
Expand Down Expand Up @@ -338,6 +340,7 @@ function App() {
<button onClick={loadStreamWithExistingInstance}>
Load stream with existing hls/shaka instance
</button>
<button onClick={createInNewTab}>Create in new tab</button>
</div>
</div>
<div style={{ display: "flex", justifyContent: "center" }}>
Expand Down
6 changes: 5 additions & 1 deletion packages/p2p-media-loader-core/src/p2p/tracker-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ export class P2PTrackerClient {
},
this.settings
);
this.logger(`connected with peer: ${peerItem.peer.id}`);
this.logger(
`connected with peer: ${peerItem.peer.id} ${LoggerUtils.getStreamString(
this.stream
)}`
);
this.eventHandlers.onPeerConnected(peerItem.peer);
});
};
Expand Down
1 change: 1 addition & 0 deletions packages/p2p-media-loader-shaka/src/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export class Engine {
this.destroyCurrentStreamContext();
this.updateMediaElementEventHandlers("unregister");
};

private destroyCurrentStreamContext = () => {
this.streamInfo.protocol = undefined;
this.streamInfo.manifestResponseUrl = undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ export class ManifestParserDecorator implements shaka.extern.ManifestParser {
this.debug(`Stream ${stream.id} is updated`);
prevFirstItemReference = firstItemReference;
prevLastItemReference = lastItemReference;
} catch (err) {
// This catch is intentionally left blank.
// [...segmentIndex] throws an error when segmentIndex inner array is empty
} finally {
segmentIndex.get = customGet;
}
Expand Down

0 comments on commit 13ccdba

Please sign in to comment.