Skip to content

Commit

Permalink
fix rounding issue
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasz-oponowicz committed Nov 13, 2014
1 parent fdb2b81 commit dda8cda
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
Binary file modified site/demo/debug/dashas.swf
Binary file not shown.
Binary file modified site/demo/production/dashas.swf
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,14 @@ public class AudioSegmentHandler extends MediaSegmentHandler {
super(context, segment, messages, defaultSampleDuration, timescale, timestamp);
}

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

message.markAsAudio();

message.timestamp = _timestamp;
_timestamp = message.timestamp + sampleDuration * 1000 / _timescale;

message.timestamp = sampleTimestamp;
message.length = sampleSize;

message.dataOffset = dataOffset;

message.data = new ByteArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,17 @@ public class MediaSegmentHandler extends SegmentHandler {
var dataOffset:uint = runBox.dataOffset + baseDataOffset;
var sampleSizes:Vector.<uint> = runBox.sampleSize;

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

var message:FLVTag = buildMessage(sampleDuration, sampleSizes[i], sampleDependsOn, sampleIsDependedOn,
samplesDuration += sampleDuration;
var sampleTimestamp:Number = _timestamp + ((samplesDuration * 1000) / _timescale);

var message:FLVTag = buildMessage(sampleTimestamp, sampleSizes[i], sampleDependsOn, sampleIsDependedOn,
compositionTimeOffset, dataOffset, ba);

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

protected function buildMessage(sampleDuration:uint, sampleSize:uint, sampleDependsOn:uint,
protected function buildMessage(sampleTimestamp:Number, sampleSize:uint, sampleDependsOn:uint,
sampleIsDependedOn:uint, compositionTimeOffset:Number,
dataOffset:uint, ba:ByteArray):FLVTag {
throw new IllegalOperationError("Method isn't implemented");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,20 @@ import com.castlabs.dash.boxes.FLVTag;
import flash.utils.ByteArray;

public class VideoSegmentHandler extends MediaSegmentHandler {
private static const MIN_CTO:int = -33;

public function VideoSegmentHandler(context:DashContext, segment:ByteArray, messages:Vector.<FLVTag>,
defaultSampleDuration:uint, timescale:uint, timestamp:Number) {
super(context, segment, messages, defaultSampleDuration, timescale, timestamp);
}

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

message.markAsVideo();

message.timestamp = _timestamp;
_timestamp = message.timestamp + sampleDuration * 1000 / _timescale;

message.timestamp = sampleTimestamp;
message.length = sampleSize;

message.dataOffset = dataOffset;

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

if (!isNaN(compositionTimeOffset)) {
message.compositionTimestamp = compositionTimeOffset * 1000 / _timescale - MIN_CTO;
message.compositionTimestamp = compositionTimeOffset * 1000 / _timescale;
}

return message;
Expand Down

6 comments on commit dda8cda

@gberkman
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

During the last tests on my player, some of our videos hesitates a little bit at the transition moment between segments while playing. But, when I tested the same manifest file on http://dashas.castlabs.com/demo/try.html, the transition is smooth. Our segments are of 10 seconds length. Is this little problem about "fix rounding issue" or something else. (I still use last release 1.0.2)

@tomasz-oponowicz
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. This commit should rather improve things...

Can you point me to your test stream?

@gberkman
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

here is the manifest file : http://185.7.176.139/videos/7977659/Manifest.mpd

@tomasz-oponowicz
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi

Demo page uses the latest version from master branch. I made next release "1.0.3" which includes these changes. For more information please visit https://github.com/castlabs/dashas/releases/tag/1.0.3

@gberkman
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tomasz hi,

thank you for your support and attention. I just want to ask an issue about seeking: if we seek to a second which is smaller than loadedtimestamp (already loaded), dashstream, always resets fragments and start loading from nearest fragment to target timestamp. Have you ever work on seeking a timestamp already loaded, without reset and reloading fragments?
For example, if current second is 5 and loaded timestamp is 20, when I seek to second 15, altough this timestamp seems to loaded already, plugin resets fragments and starts to load from nearest segment to second 15.
When I cancel fragment loading action in this case (insert an if flag) and call only NetStream.seek(second), stream just freezes. Do you think is it possible to simply jump to already loaded second (just like ordinary progessive video)?

@tomasz-oponowicz
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually Flash limitation. Dashas immediately append every loaded fragment to a buffer of the Netstream. The NetStream, in appendByte mode, doesn't allow to jump to forward or backward in the buffer.

The workaround might be to store segments in a queue and append them when they are needed. The net effect would be jumping between segments.

I'm afraid you can't achieve very precise seek (within a segment) because Flash has to start from I-frame and usually small segments (5-10 seconds) have 1-2 I-frames.

If you were any solution, please share it with us.

Please sign in to comment.