[media-source] Have appendBuffer and remove return promise.

jyavenard has just created a new issue for 
https://github.com/w3c/media-source:

== Have appendBuffer and remove return promise. ==
I realise this is late in the lifecycle ; but I believe this would be 
a great improvement to the current spec and be fully backward 
compatible with the existing spec.

SourceBuffer::appendBuffer and SourceBuffer::remove should now return 
a promise.

Such promise will be resolved when either of those calls will 
complete.
Promise will be rejected with the error code whenever an error 
occurred and optionally extra details explaining the error (this would
 make troubleshooting much easier, like explaining what was wrong in 
the data being added).

I intend to provide further implementation details in a following 
post.

However, the general guideline would be that whenever in the current 
text we read:
"Queue a task to fire a simple event named update at this SourceBuffer
 object.
Queue a task to fire a simple event named updateend at this 
SourceBuffer object."

would now read:
"Queue a task to fire a simple event named update at this SourceBuffer
 object.
Queue a task to fire a simple event named updateend at this 
SourceBuffer object.
Resolve the current pending promise"

where we read:
"Queue a task to fire a simple event named abort at sourceBuffer.
Queue a task to fire a simple event named updateend at sourceBuffer."
would now read:
"Queue a task to fire a simple event named abort at sourceBuffer.
Queue a task to fire a simple event named updateend at sourceBuffer.
Reject the current pending promise with MEDIA_ERR_ABORTED"

where we read:
"Queue a task to fire a simple event named error at this SourceBuffer 
object.
Queue a task to fire a simple event named updateend at this 
SourceBuffer object."
would now read:
Queue a task to fire a simple event named error at this SourceBuffer 
object.
Queue a task to fire a simple event named updateend at this 
SourceBuffer object.
Reject the current pending promise with decode error"

the decode error could be augmented such as it contains the actual 
error code that originally caused the error.

Where in appendBuffer and remove we read:
"If the updating attribute equals true, then throw an 
InvalidStateError exception and abort these steps."

would now read:
"If the updating attribute equals true, then throw an 
InvalidStateError exception, return a rejected promise with 
InvalidStateError error and abort these steps."

Those changes are fully backward compatible with existing 
implementation and use, but it will make things much simpler to use 
for the clients than having to deal with the various "update*" events 
being fired.

Firefox/Gecko can implement those changes very quickly (a few days)

Please view or discuss this issue at 
https://github.com/w3c/media-source/issues/100 using your GitHub 
account

Received on Friday, 17 June 2016 12:29:51 UTC