Skip to content

Commit

Permalink
feat(avutil): analyzeUrlIOLoader 支持处理 ws、wss、webtransport 协议的 url
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaohappy committed Dec 20, 2024
1 parent 65a4f78 commit 091ba47
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/avutil/function/analyzeUrlIOLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,24 @@ export default async function analyzeUrlIOLoader(source: string, defaultExt: str
}
}
else {

const protocol = urlUtils.parse(source).protocol

ext = defaultExt || urlUtils.parse(source).file.split('.').pop()
// 没有文件后缀,我们需要分析是不是 m3u8 和 mpd 文件
// 这两种格式需要提前知道来创建指定的 ioloader
if (!ext) {
if (!ext && /^https?/.test(protocol)) {
ext = await analyzeUrlFileExt(source, httpOptions)
}
type = Ext2IOLoader[ext] ?? IOType.Fetch

let defaultType: IOType = IOType.Fetch
if (protocol === 'wss' || protocol === 'ws') {
defaultType = IOType.WEBSOCKET
}
else if (protocol === 'webtransport') {
defaultType = IOType.WEBTRANSPORT
}
type = Ext2IOLoader[ext] ?? defaultType
}

return {
Expand Down

0 comments on commit 091ba47

Please sign in to comment.