{"action":"created","issue":{"url":"https://api.github.com/repos/google/shaka-player/issues/411","repository_url":"https://api.github.com/repos/google/shaka-player","labels_url":"https://api.github.com/repos/google/shaka-player/issues/411/labels{/name}","comments_url":"https://api.github.com/repos/google/shaka-player/issues/411/comments","events_url":"https://api.github.com/repos/google/shaka-player/issues/411/events","html_url":"https://github.com/google/shaka-player/pull/411","id":159540112,"number":411,"title":"Do not apply offset to startTime/endTime for text buffer","user":{"login":"baconz","id":1123782,"avatar_url":"https://avatars.githubusercontent.com/u/1123782?v=3","gravatar_id":"","url":"https://api.github.com/users/baconz","html_url":"https://github.com/baconz","followers_url":"https://api.github.com/users/baconz/followers","following_url":"https://api.github.com/users/baconz/following{/other_user}","gists_url":"https://api.github.com/users/baconz/gists{/gist_id}","starred_url":"https://api.github.com/users/baconz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baconz/subscriptions","organizations_url":"https://api.github.com/users/baconz/orgs","repos_url":"https://api.github.com/users/baconz/repos","events_url":"https://api.github.com/users/baconz/events{/privacy}","received_events_url":"https://api.github.com/users/baconz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"joeyparrish","id":6843156,"avatar_url":"https://avatars.githubusercontent.com/u/6843156?v=3","gravatar_id":"","url":"https://api.github.com/users/joeyparrish","html_url":"https://github.com/joeyparrish","followers_url":"https://api.github.com/users/joeyparrish/followers","following_url":"https://api.github.com/users/joeyparrish/following{/other_user}","gists_url":"https://api.github.com/users/joeyparrish/gists{/gist_id}","starred_url":"https://api.github.com/users/joeyparrish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joeyparrish/subscriptions","organizations_url":"https://api.github.com/users/joeyparrish/orgs","repos_url":"https://api.github.com/users/joeyparrish/repos","events_url":"https://api.github.com/users/joeyparrish/events{/privacy}","received_events_url":"https://api.github.com/users/joeyparrish/received_events","type":"User","site_admin":false},"assignees":[{"login":"joeyparrish","id":6843156,"avatar_url":"https://avatars.githubusercontent.com/u/6843156?v=3","gravatar_id":"","url":"https://api.github.com/users/joeyparrish","html_url":"https://github.com/joeyparrish","followers_url":"https://api.github.com/users/joeyparrish/followers","following_url":"https://api.github.com/users/joeyparrish/following{/other_user}","gists_url":"https://api.github.com/users/joeyparrish/gists{/gist_id}","starred_url":"https://api.github.com/users/joeyparrish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joeyparrish/subscriptions","organizations_url":"https://api.github.com/users/joeyparrish/orgs","repos_url":"https://api.github.com/users/joeyparrish/repos","events_url":"https://api.github.com/users/joeyparrish/events{/privacy}","received_events_url":"https://api.github.com/users/joeyparrish/received_events","type":"User","site_admin":false}],"milestone":null,"comments":5,"created_at":"2016-06-10T01:01:22Z","updated_at":"2016-06-30T15:29:47Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/google/shaka-player/pulls/411","html_url":"https://github.com/google/shaka-player/pull/411","diff_url":"https://github.com/google/shaka-player/pull/411.diff","patch_url":"https://github.com/google/shaka-player/pull/411.patch"},"body":"The start/end times are derived from reference times which have\r\nalready had the offsets applied. Without this patch, when there\r\nis an offset present we buffer all available text segments at\r\nstream start."},"comment":{"url":"https://api.github.com/repos/google/shaka-player/issues/comments/229695454","html_url":"https://github.com/google/shaka-player/pull/411#issuecomment-229695454","issue_url":"https://api.github.com/repos/google/shaka-player/issues/411","id":229695454,"user":{"login":"baconz","id":1123782,"avatar_url":"https://avatars.githubusercontent.com/u/1123782?v=3","gravatar_id":"","url":"https://api.github.com/users/baconz","html_url":"https://github.com/baconz","followers_url":"https://api.github.com/users/baconz/followers","following_url":"https://api.github.com/users/baconz/following{/other_user}","gists_url":"https://api.github.com/users/baconz/gists{/gist_id}","starred_url":"https://api.github.com/users/baconz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baconz/subscriptions","organizations_url":"https://api.github.com/users/baconz/orgs","repos_url":"https://api.github.com/users/baconz/repos","events_url":"https://api.github.com/users/baconz/events{/privacy}","received_events_url":"https://api.github.com/users/baconz/received_events","type":"User","site_admin":false},"created_at":"2016-06-30T15:29:47Z","updated_at":"2016-06-30T15:29:47Z","body":"Let me try to be explicit about what I believe that I'm seeing in the text flow. I'm glossing over many parts of the system, but this is how I understand it:\r\n\r\n1. References are created in `SegmentList.parseSegmentListInfo_` and have the PTO applied to their start and end times. Now all the references have times relative to the period start, not the AST.\r\n1. `StreamingEngine` decides the references need to be buffered, and we end up in `fetchAndAppend`, which calls `initSourceBuffer` on the current period\r\n1. We set the `timestampOffset` on the media source to **period start - PTO**. The `timestampOffset` _is relative to the AST_. Please correct me if I'm wrong about this assumption.\r\n1. Once we fetch the segments they get passed through to `StreamingEngine.append_`, which calls `StreamingEngine.appendBuffer_` **using the start and end times of the references**. Per my assumption above, these times are period relative.\r\n1. Now we arrive at `TextEngine.appendBuffer`, which is adding the offset to the the reference start/end times. As I see it, the math we are doing is: \r\n```\r\nreferenceTime = origTs - PTO\r\noffset = periodStart - PTO\r\nnewReferenceTime = referenceTime + offset\r\n```\r\n\r\nwhere `referenceTime` is `startTime` or `endTime` in `TextEngine.appendBuffer`. This can be rewritten as\r\n\r\n```\r\nnewReferenceTime = origTs - PTO + periodStart - PTO\r\n```\r\nSo we're subtracting out the PTO twice. I think what we actually want is:\r\n\r\n```\r\nnewReferenceTime = origTs - PTO + periodStart\r\n```\r\n\r\nI think the right solution is to pass the `periodStart` into `TextEngine` so that we can add it to the reference times that we pass in to `appendBuffer`.\r\n\r\nI'm happy to move this off to an issue, if you think it is legit."}}
{"actor":{"display_login":"baconz"}}