Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/support h26611 #1431

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
a25912a
bvc2 codec support
Aug 30, 2023
c2a9425
fix: 🐛 (xgplayer-mp4-loader) 修复MP4重播时卡帧及卡顿问题
gemxx Nov 20, 2023
4e830b5
fix: 🐛 (xgplayer-transmuxer) 修复MP4音画不同步问题
gemxx Dec 19, 2023
3973237
fix: 🐛 (xgplayer-mp4-loader) 修复MP4音画不同步问题
gemxx Dec 27, 2023
f3492d9
fix: 🐛 (xgplayer-transmuxer) eslint rule
gemxx Dec 27, 2023
c81ef51
refactor: 💡 (xgplayer-mp4-loader) update transmuxer version
gemxx Dec 27, 2023
a192b95
fix: 🐛 (xgplayer-mp4-loader) 默认MP4修复edts时间偏移
gemxx Dec 27, 2023
348673d
fix: 🐛 (xgplayer-mp4-loader) 调整新方案,修复MP4音画不同步问题
gemxx Jan 18, 2024
dd5362b
release: [email protected]
gemxx Jan 18, 2024
9950e2b
fix: 🐛 (xgplayer-mp4-loader) 修复 M75+ 之前的版本对于负的 dts 开播报错问题
gemxx Jan 23, 2024
2679c57
fix: 🐛 (xgplayer-transmuxer) 修复media_time为负数时,解析数值逻辑不正确导致开播失败问题
gemxx Jan 30, 2024
e3591ee
refactor: 💡 (xgplayer-mp4-loader) 调整音频分组策略
gemxx Mar 29, 2024
1fe38bb
refactor: 💡 (xgplayer-mp4-loader) 重构音频分组策略
gemxx Apr 9, 2024
e95ebde
refactor: 💡 (xgplayer-mp4-loader) 调整音频分组策略
gemxx Apr 9, 2024
95a86f2
fix(mp4-loader): 修复stsc.entries为控诉组解析异常问题
hongqx Apr 15, 2024
f125f15
refactor: 💡 (xgplayer-mp4-loader) 为config参数增加默认值
gemxx May 8, 2024
60463ce
feat(xgplayer-transmuxer): 删除vvc相关逻辑
hongqx May 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/xgplayer-mp4-loader/src/config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
export function getConfig (cfg) {
if (typeof cfg.fixEditListOffset !== 'boolean') {
delete cfg.fixEditListOffset
}
return {
vid: '',
moovEnd: 80000,
segmentDuration: 2,
maxDownloadInfoSize: 30,
responseType: 'arraybuffer',
fixEditListOffset: true,
cache: null,
// ...xgplayer-streaming-shared/src/net/config
...cfg
Expand Down
33 changes: 16 additions & 17 deletions packages/xgplayer-mp4-loader/src/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { MP4Parser } from 'xgplayer-transmuxer'
import { getConfig } from './config'
import { MediaError } from './error'
import { Cache } from './cache'
import { isNumber, moovToMeta, moovToSegments } from './utils'
import { isNumber, moovToMeta, moovToSegments, isSegmentsOk } from './utils'
import EventEmitter from 'eventemitter3'

export class MP4Loader extends EventEmitter {
Expand Down Expand Up @@ -76,10 +76,10 @@ export class MP4Loader extends EventEmitter {
return this.meta
}

async loadMetaProcess (cache, [moovStart, moovEnd], onProgress, config) {
async loadMetaProcess (cache, [moovStart, moovEnd], onProgress, config = {}) {
this._error = false
this.logger.debug('[loadMetaProcess start], range,', [moovStart, moovEnd])
const OnProgressHandle = async (data, state, options) => {
const OnProgressHandle = async (data, state, options, response) => {
if (this.meta && options?.range && options.range.length > 0 && options.range[1] >= moovEnd) {
state = true
this.logger.debug('[loadMetaProcess],data done,setstate true,[', moovStart, moovEnd, ']')
Expand All @@ -89,7 +89,7 @@ export class MP4Loader extends EventEmitter {
this.logger.debug('[loadMetaProcess],data not done,setstate false,[', moovStart, moovEnd, ']')
}
this.logger.debug('[loadMetaProcess],task,[', moovStart, moovEnd, '], range,', options.range, ',dataLen,', (data ? data.byteLength : undefined), ', state,', state, ',err,',this._error)
!this._error && data && data.byteLength > 0 && onProgress(data, state, options)
!this._error && data && data.byteLength > 0 && onProgress(data, state, options, null, response)
if (this.meta.moov || this._error) return
if (data && data.byteLength > 0) {
this.buffer = concatUint8Array(this.buffer, data)
Expand All @@ -99,7 +99,7 @@ export class MP4Loader extends EventEmitter {
if (state) {
if (!mdat) {
this._error = true
onProgress(null, state, options, {err:'cannot find moov or mdat box'})
onProgress(null, state, options, new MediaError('cannot find moov or mdat box'), response)
return
// throw new MediaError('cannot find moov or mdat box')
} else {
Expand All @@ -119,15 +119,15 @@ export class MP4Loader extends EventEmitter {
const parsedMoov = MP4Parser.moov(moov)
if (!parsedMoov) {
this._error = true
onProgress(null, state, options, {err:'cannot parse moov box'})
onProgress(null, state, options, new MediaError('cannot parse moov box'), response)
return
// throw new MediaError('cannot parse moov box', moov.data)
}

const segments = moovToSegments(parsedMoov, this._config.segmentDuration)
if (!segments) {
const segments = moovToSegments(parsedMoov, this._config)
if (!isSegmentsOk(segments)) {
this._error = true
onProgress(null, state, options, {err:'cannot parse segments'})
onProgress(null, state, options, new MediaError('cannot parse segments'), response)
return
// throw new MediaError('cannot parse segments', moov.data)
}
Expand All @@ -143,14 +143,14 @@ export class MP4Loader extends EventEmitter {
videoSegments,
audioSegments
}
})
}, null, response)
}
}
}
await this.loadData([moovStart, moovEnd || this._config.moovEnd], cache, { onProgress: OnProgressHandle, ...config})
}

async loadMeta (cache, moovEnd, config) {
async loadMeta (cache, moovEnd, config = {}) {
const responses = []
this.logger.debug('[loadMeta start]')
let res = await this.loadData([0, moovEnd || this._config.moovEnd], cache, config)
Expand Down Expand Up @@ -181,9 +181,8 @@ export class MP4Loader extends EventEmitter {
if (!parsedMoov) {
throw new MediaError('cannot parse moov box', moov.data)
}

const segments = moovToSegments(parsedMoov, this._config.segmentDuration)
if (!segments) {
const segments = moovToSegments(parsedMoov, this._config)
if (!isSegmentsOk(segments)) {
throw new MediaError('cannot parse segments', moov.data)
}

Expand All @@ -202,7 +201,7 @@ export class MP4Loader extends EventEmitter {

loadCacheMeta (meta, segmentIndex){
const { moov } = meta
const segments = moovToSegments(moov, this._config.segmentDuration)
const segments = moovToSegments(moov, this._config)
const { videoSegments, audioSegments } = segments
this.videoSegments = videoSegments
this.audioSegments = audioSegments
Expand Down Expand Up @@ -315,12 +314,12 @@ export class MP4Loader extends EventEmitter {
return res
}

async loadData (range, cache, config) {
async loadData (range, cache, config = {}) {
const cacheKey = this._getCacheKey(range)
const data = await this.cache.get(cacheKey)
let res
if (!data) {
const url = config && config.url ? config.url : this.url
const url = config?.url ? config.url : this.url
res = await this._loader.load(url, { range, vid: this.vid, ...config })
} else {
res = { data, state: true, options: { fromCache: true, range, vid: this.vid } }
Expand Down
Loading