-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework duration / buffered ranges handling
- Loading branch information
Showing
2 changed files
with
105 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,22 @@ | ||
import typing | ||
import protobug | ||
import math | ||
|
||
|
||
@protobug.message | ||
class TimeRange: | ||
start: typing.Optional[protobug.Int64] = protobug.field(1, default=None) | ||
duration: typing.Optional[protobug.Int64] = protobug.field(2, default=None) | ||
timescale: typing.Optional[protobug.Int32] = protobug.field(3, default=None) | ||
timescale: typing.Optional[protobug.Int32] = protobug.field(3, default=None) | ||
|
||
def get_duration_ms(self): | ||
if not self.duration or not self.timescale: | ||
return None | ||
|
||
return math.ceil((self.duration / self.timescale) * 1000) | ||
|
||
def get_start_ms(self): | ||
if not self.start or not self.timescale: | ||
return None | ||
|
||
return math.ceil((self.start / self.timescale) * 1000) |