Skip to content

Commit

Permalink
TransmuxingController: Only pass PTS for recommend_seekpoint if Safari
Browse files Browse the repository at this point in the history
  • Loading branch information
xqq committed Sep 21, 2016
1 parent a72ecf2 commit 38f7d0b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ flv.js is written in [ECMAScript 6][], and transpiled into ECMAScript 5 by [Babe
- Multipart segmented video playback
- HTTP FLV low latency live stream playback
- FLV over WebSocket live stream playback
- Compatible with Chrome, FireFox, IE11 and Edge
- Compatible with Chrome, FireFox, Safari 10, IE11 and Edge
- Extermely low overhead, and hardware accelerated by your browser!

### Build
Expand Down
1 change: 1 addition & 0 deletions src/core/mse-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ class MSEController {

// Safari 10 may get InvalidStateError in the later appendBuffer() after SourceBuffer.remove() call
// Internal parser's state may be invalid at this time. Re-append last InitSegment to workaround.
// Related issue: https://bugs.webkit.org/show_bug.cgi?id=159230
if (Browser.safari) {
let lastInitSegment = this._lastInitSegments[type];
if (lastInitSegment) {
Expand Down
8 changes: 5 additions & 3 deletions src/core/transmuxing-controller.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import EventEmitter from 'events';
import Log from '../utils/logger.js';
import Browser from '../utils/browser.js';
import MediaInfo from './media-info.js';
import FlvDemuxer from '../demux/flv-demuxer.js';
import MP4Remuxer from '../remux/mp4-remuxer.js';
Expand Down Expand Up @@ -157,7 +158,7 @@ class TransmuxingController {
let keyframe = segmentInfo.getNearestKeyframe(milliseconds);
this._remuxer.seek(keyframe.milliseconds);
this._ioctl.seek(keyframe.fileposition);
// Will be resolved in @_onRemuxerMediaSegmentArrival
// Will be resolved in _onRemuxerMediaSegmentArrival()
this._pendingResolveSeekPoint = keyframe.milliseconds;
}
} else {
Expand Down Expand Up @@ -312,12 +313,13 @@ class TransmuxingController {
}
this._emitter.emit(TransmuxingEvents.MEDIA_SEGMENT, type, mediaSegment);

if (this._pendingResolveSeekPoint != null) {
if (this._pendingResolveSeekPoint != null && type === 'video') {
let syncPoints = mediaSegment.info.syncPoints;
let seekpoint = this._pendingResolveSeekPoint;
this._pendingResolveSeekPoint = null;

if (syncPoints.length > 0 && syncPoints[0].originalDts === seekpoint) {
// Safari: Pass PTS for recommend_seekpoint
if (Browser.safari && syncPoints.length > 0 && syncPoints[0].originalDts === seekpoint) {
seekpoint = syncPoints[0].pts;
}
// else: use original DTS (keyframe.milliseconds)
Expand Down

0 comments on commit 38f7d0b

Please sign in to comment.