{"action":"created","issue":{"url":"https://api.github.com/repos/dailymotion/hls.js/issues/100","labels_url":"https://api.github.com/repos/dailymotion/hls.js/issues/100/labels{/name}","comments_url":"https://api.github.com/repos/dailymotion/hls.js/issues/100/comments","events_url":"https://api.github.com/repos/dailymotion/hls.js/issues/100/events","html_url":"https://github.com/dailymotion/hls.js/issues/100","id":119458847,"number":100,"title":"Implement configurable buffer garbage collection strategy","user":{"login":"AxelDelmas","id":5991128,"avatar_url":"https://avatars.githubusercontent.com/u/5991128?v=3","gravatar_id":"","url":"https://api.github.com/users/AxelDelmas","html_url":"https://github.com/AxelDelmas","followers_url":"https://api.github.com/users/AxelDelmas/followers","following_url":"https://api.github.com/users/AxelDelmas/following{/other_user}","gists_url":"https://api.github.com/users/AxelDelmas/gists{/gist_id}","starred_url":"https://api.github.com/users/AxelDelmas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AxelDelmas/subscriptions","organizations_url":"https://api.github.com/users/AxelDelmas/orgs","repos_url":"https://api.github.com/users/AxelDelmas/repos","events_url":"https://api.github.com/users/AxelDelmas/events{/privacy}","received_events_url":"https://api.github.com/users/AxelDelmas/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-30T10:03:43Z","updated_at":"2015-12-01T15:55:53Z","closed_at":null,"body":"I'm thinking of something equivalent to [backBufferTime](http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/NetStream.html#backBufferTime) for NetStream. This is related to #88, but I filed it as a different issue, as this is an enhancement whereas `QuotaExceededError` needs to be correctly handled anyway.\r\n\r\nThe reason is there are plenty of use cases where we don't need to cache already displayed data (live without DVR for example), and then it doesn't make sense to use RAM to keep that data in buffer for nothing.\r\n\r\nA pretty simple way to do that is to loop over SourceBuffer.buffered ranges, remove the ones that don't include video.currentTime (at least the ranges that are behind the playback position), and remove the beginning of the range that does include video.currentTime, up to (currentTime - N), where N is a number of seconds configurable at player setup (might be Infinity by default).\r\n\r\nThis would imply handling \"concurrency\" between append and remove tasks, so having some sort of queue wrapping the SourceBuffer. I see there's a mp4segments array [here](https://github.com/dailymotion/hls.js/blob/master/src/controller/mse-media-controller.js#L372), but it seems that there's still only one segment being appended at a time (segments in this array are mp4 boxes of the same segment if I'm not mistaken).\r\n\r\nThis queue system would also allow to fetch the next segment while the current one is being transmuxed / appended, which I'm not sure is possible now with the state system used in mse-media-controller (as per https://github.com/dailymotion/hls.js/blob/master/src/controller/mse-media-controller.js#L356-L358)"},"comment":{"url":"https://api.github.com/repos/dailymotion/hls.js/issues/comments/161010339","html_url":"https://github.com/dailymotion/hls.js/issues/100#issuecomment-161010339","issue_url":"https://api.github.com/repos/dailymotion/hls.js/issues/100","id":161010339,"user":{"login":"AxelDelmas","id":5991128,"avatar_url":"https://avatars.githubusercontent.com/u/5991128?v=3","gravatar_id":"","url":"https://api.github.com/users/AxelDelmas","html_url":"https://github.com/AxelDelmas","followers_url":"https://api.github.com/users/AxelDelmas/followers","following_url":"https://api.github.com/users/AxelDelmas/following{/other_user}","gists_url":"https://api.github.com/users/AxelDelmas/gists{/gist_id}","starred_url":"https://api.github.com/users/AxelDelmas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AxelDelmas/subscriptions","organizations_url":"https://api.github.com/users/AxelDelmas/orgs","repos_url":"https://api.github.com/users/AxelDelmas/repos","events_url":"https://api.github.com/users/AxelDelmas/events{/privacy}","received_events_url":"https://api.github.com/users/AxelDelmas/received_events","type":"User","site_admin":false},"created_at":"2015-12-01T15:55:53Z","updated_at":"2015-12-01T15:55:53Z","body":"Right! Seems to be the first logical step indeed"}}