MediaDrmBridge: NotifyNewKey() after the key has been added.
commit94cf2e6dccd1890bc88ea0df37af1229570b2713
authorxhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Thu, 26 Jun 2014 05:47:02 +0000 (26 05:47 +0000)
committerxhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Thu, 26 Jun 2014 05:47:02 +0000 (26 05:47 +0000)
tree855cc31768b3543966b320805606d88f01e2875f
parent2e4d70da766e46545caad8099af2f061de672f10
MediaDrmBridge: NotifyNewKey() after the key has been added.

Previously we NotifyNewKey() immediately after we call UpdateSession(). This
could cause unnecessary delay in playback start. For example:

1, QueueSecureInputBuffer();
2, Decode error due to NoKey.
3, UpdateSession() called. NotifyNewKey() is called immediately after. Since
MediaSourcePlayer hasn't received MEDIA_CODEC_NO_KEY yet. |is_waiting_for_key_|
is false. Therefore, there's not need to try to decode again.
4, MediaDecoderCallback with MEDIA_CODEC_NO_KEY received in MediaSourcePlayer.
The player is waiting for new key to be added even though the new key has
already been added.
5, Video is not playing................
6, MediaDrm renews the key after the renewal duration has passed, e.g. 4 sec.
7, UpdateSession() called again. NotifyNewKey() is called immediately after,
which calls StartInternal() in MediaSourcePlayer since it |is_waiting_for_key_|.

In the above scenario, the worst case is that the playback will be paused for
the renewal duration. This is unnecessary. We can NotifyNewKey() after the key
has been added. This will dramatically reduce the chance of the above scenario
to happen.

BUG=388798
TEST=Playback starts immediately.
R=jrummell@chromium.org

Review URL: https://codereview.chromium.org/352863003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@279912 0039d316-1c4b-4281-b951-d872f2087c98
media/base/android/media_drm_bridge.cc