Skip to content

Commit dda8cda

Browse files
fix rounding issue
1 parent fdb2b81 commit dda8cda

File tree

5 files changed

+11
-16
lines changed

5 files changed

+11
-16
lines changed

site/demo/debug/dashas.swf

-38 Bytes
Binary file not shown.

site/demo/production/dashas.swf

73.3 KB
Binary file not shown.

src/main/actionscript/com/castlabs/dash/handlers/AudioSegmentHandler.as

+2-6
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,14 @@ public class AudioSegmentHandler extends MediaSegmentHandler {
1818
super(context, segment, messages, defaultSampleDuration, timescale, timestamp);
1919
}
2020

21-
protected override function buildMessage(sampleDuration:uint, sampleSize:uint, sampleDependsOn:uint,
21+
protected override function buildMessage(sampleTimestamp:Number, sampleSize:uint, sampleDependsOn:uint,
2222
sampleIsDependedOn:uint, compositionTimeOffset:Number,
2323
dataOffset:uint, ba:ByteArray):FLVTag {
2424
var message:FLVTag = _context.buildFLVTag();
2525

2626
message.markAsAudio();
27-
28-
message.timestamp = _timestamp;
29-
_timestamp = message.timestamp + sampleDuration * 1000 / _timescale;
30-
27+
message.timestamp = sampleTimestamp;
3128
message.length = sampleSize;
32-
3329
message.dataOffset = dataOffset;
3430

3531
message.data = new ByteArray();

src/main/actionscript/com/castlabs/dash/handlers/MediaSegmentHandler.as

+6-2
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,17 @@ public class MediaSegmentHandler extends SegmentHandler {
9494
var dataOffset:uint = runBox.dataOffset + baseDataOffset;
9595
var sampleSizes:Vector.<uint> = runBox.sampleSize;
9696

97+
var samplesDuration:uint = 0;
9798
for (var i:uint = 0; i < sampleSizes.length; i++) {
9899
var sampleDuration:uint = loadSampleDuration(runBox, i);
99100
var compositionTimeOffset:int = loadCompositionTimeOffset(runBox, i);
100101
var sampleDependsOn:uint = loadSampleDependsOn(runBox, i);
101102
var sampleIsDependedOn:uint = loadSampleIsDependedOn(runBox, i);
102103

103-
var message:FLVTag = buildMessage(sampleDuration, sampleSizes[i], sampleDependsOn, sampleIsDependedOn,
104+
samplesDuration += sampleDuration;
105+
var sampleTimestamp:Number = _timestamp + ((samplesDuration * 1000) / _timescale);
106+
107+
var message:FLVTag = buildMessage(sampleTimestamp, sampleSizes[i], sampleDependsOn, sampleIsDependedOn,
104108
compositionTimeOffset, dataOffset, ba);
105109

106110
_messages.push(message);
@@ -125,7 +129,7 @@ public class MediaSegmentHandler extends SegmentHandler {
125129
return i < runBox.sampleIsDependedOn.length ? runBox.sampleIsDependedOn[i] : 0;
126130
}
127131

128-
protected function buildMessage(sampleDuration:uint, sampleSize:uint, sampleDependsOn:uint,
132+
protected function buildMessage(sampleTimestamp:Number, sampleSize:uint, sampleDependsOn:uint,
129133
sampleIsDependedOn:uint, compositionTimeOffset:Number,
130134
dataOffset:uint, ba:ByteArray):FLVTag {
131135
throw new IllegalOperationError("Method isn't implemented");

src/main/actionscript/com/castlabs/dash/handlers/VideoSegmentHandler.as

+3-8
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,20 @@ import com.castlabs.dash.boxes.FLVTag;
1313
import flash.utils.ByteArray;
1414

1515
public class VideoSegmentHandler extends MediaSegmentHandler {
16-
private static const MIN_CTO:int = -33;
17-
1816
public function VideoSegmentHandler(context:DashContext, segment:ByteArray, messages:Vector.<FLVTag>,
1917
defaultSampleDuration:uint, timescale:uint, timestamp:Number) {
2018
super(context, segment, messages, defaultSampleDuration, timescale, timestamp);
2119
}
2220

23-
protected override function buildMessage(sampleDuration:uint, sampleSize:uint, sampleDependsOn:uint,
21+
protected override function buildMessage(sampleTimestamp:Number, sampleSize:uint, sampleDependsOn:uint,
2422
sampleIsDependedOn:uint, compositionTimeOffset:Number,
2523
dataOffset:uint, ba:ByteArray):FLVTag {
2624
var message:FLVTag = _context.buildFLVTag();
2725

2826
message.markAsVideo();
2927

30-
message.timestamp = _timestamp;
31-
_timestamp = message.timestamp + sampleDuration * 1000 / _timescale;
32-
28+
message.timestamp = sampleTimestamp;
3329
message.length = sampleSize;
34-
3530
message.dataOffset = dataOffset;
3631

3732
message.data = new ByteArray();
@@ -49,7 +44,7 @@ public class VideoSegmentHandler extends MediaSegmentHandler {
4944
}
5045

5146
if (!isNaN(compositionTimeOffset)) {
52-
message.compositionTimestamp = compositionTimeOffset * 1000 / _timescale - MIN_CTO;
47+
message.compositionTimestamp = compositionTimeOffset * 1000 / _timescale;
5348
}
5449

5550
return message;

0 commit comments

Comments
 (0)