OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/media/crypto/ppapi_decryptor.h" | 5 #include "content/renderer/media/crypto/ppapi_decryptor.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 10 matching lines...) Expand all Loading... | |
21 #include "media/base/data_buffer.h" | 21 #include "media/base/data_buffer.h" |
22 #include "media/base/decoder_buffer.h" | 22 #include "media/base/decoder_buffer.h" |
23 #include "media/base/video_decoder_config.h" | 23 #include "media/base/video_decoder_config.h" |
24 #include "media/base/video_frame.h" | 24 #include "media/base/video_frame.h" |
25 | 25 |
26 namespace content { | 26 namespace content { |
27 | 27 |
28 // This class is needed so that resolving an Update() promise triggers playback | 28 // This class is needed so that resolving an Update() promise triggers playback |
29 // of the stream. It intercepts the resolve() call to invoke an additional | 29 // of the stream. It intercepts the resolve() call to invoke an additional |
30 // callback. | 30 // callback. |
31 class SessionUpdatedPromise : public media::SimpleCdmPromise { | 31 class SessionUpdatedPromise : public media::CdmPromiseTemplate<void> { |
ddorwin
2014/09/26 22:40:00
Would CdmCallbackPromise be a better fit (even if
jrummell
2014/09/29 22:08:38
Nope. It needs to call resolve/reject on the passe
| |
32 public: | 32 public: |
33 SessionUpdatedPromise(scoped_ptr<media::SimpleCdmPromise> caller_promise, | 33 SessionUpdatedPromise(scoped_ptr<media::SimpleCdmPromise> caller_promise, |
34 base::Closure additional_resolve_cb) | 34 base::Closure additional_resolve_cb) |
35 : caller_promise_(caller_promise.Pass()), | 35 : caller_promise_(caller_promise.Pass()), |
36 additional_resolve_cb_(additional_resolve_cb) {} | 36 additional_resolve_cb_(additional_resolve_cb) {} |
37 | 37 |
38 virtual void resolve() OVERRIDE { | 38 virtual void resolve() OVERRIDE { |
ddorwin
2014/09/26 22:40:00
Note that there is currently no is_pending_ check
jrummell
2014/09/29 22:08:38
Done.
| |
39 DCHECK(is_pending_); | |
40 is_pending_ = false; | |
41 additional_resolve_cb_.Run(); | 39 additional_resolve_cb_.Run(); |
42 caller_promise_->resolve(); | 40 caller_promise_->resolve(); |
43 } | 41 } |
44 | 42 |
45 virtual void reject(media::MediaKeys::Exception exception_code, | 43 virtual void reject(media::MediaKeys::Exception exception_code, |
46 uint32 system_code, | 44 uint32 system_code, |
47 const std::string& error_message) OVERRIDE { | 45 const std::string& error_message) OVERRIDE { |
48 DCHECK(is_pending_); | |
49 is_pending_ = false; | |
50 caller_promise_->reject(exception_code, system_code, error_message); | 46 caller_promise_->reject(exception_code, system_code, error_message); |
51 } | 47 } |
52 | 48 |
53 protected: | 49 protected: |
54 scoped_ptr<media::SimpleCdmPromise> caller_promise_; | 50 scoped_ptr<media::SimpleCdmPromise> caller_promise_; |
55 base::Closure additional_resolve_cb_; | 51 base::Closure additional_resolve_cb_; |
56 }; | 52 }; |
57 | 53 |
58 // This class is needed so that resolving a SessionLoaded() promise triggers | 54 // This class is needed so that resolving a SessionLoaded() promise triggers |
59 // playback of the stream. It intercepts the resolve() call to invoke an | 55 // playback of the stream. It intercepts the resolve() call to invoke an |
60 // additional callback. This is only needed until KeysChange event gets passed | 56 // additional callback. This is only needed until KeysChange event gets passed |
61 // through Pepper. | 57 // through Pepper. |
62 class SessionLoadedPromise : public media::NewSessionCdmPromise { | 58 class SessionLoadedPromise : public media::CdmPromiseTemplate<std::string> { |
xhwang
2014/09/29 18:32:58
Can we merge SessionUpdatedPromise and SessionLoad
jrummell
2014/09/29 22:08:38
Could be done, although it would be no less code.
| |
63 public: | 59 public: |
64 SessionLoadedPromise(scoped_ptr<media::NewSessionCdmPromise> caller_promise, | 60 SessionLoadedPromise(scoped_ptr<media::NewSessionCdmPromise> caller_promise, |
65 base::Closure additional_resolve_cb) | 61 base::Closure additional_resolve_cb) |
66 : caller_promise_(caller_promise.Pass()), | 62 : caller_promise_(caller_promise.Pass()), |
67 additional_resolve_cb_(additional_resolve_cb) {} | 63 additional_resolve_cb_(additional_resolve_cb) {} |
68 | 64 |
69 virtual void resolve(const std::string& web_session_id) OVERRIDE { | 65 virtual void resolve(const std::string& web_session_id) OVERRIDE { |
70 DCHECK(is_pending_); | |
71 is_pending_ = false; | |
72 additional_resolve_cb_.Run(); | 66 additional_resolve_cb_.Run(); |
73 caller_promise_->resolve(web_session_id); | 67 caller_promise_->resolve(web_session_id); |
74 } | 68 } |
75 | 69 |
76 virtual void reject(media::MediaKeys::Exception exception_code, | 70 virtual void reject(media::MediaKeys::Exception exception_code, |
77 uint32 system_code, | 71 uint32 system_code, |
78 const std::string& error_message) OVERRIDE { | 72 const std::string& error_message) OVERRIDE { |
79 DCHECK(is_pending_); | |
80 is_pending_ = false; | |
81 caller_promise_->reject(exception_code, system_code, error_message); | 73 caller_promise_->reject(exception_code, system_code, error_message); |
82 } | 74 } |
83 | 75 |
84 protected: | 76 protected: |
85 scoped_ptr<media::NewSessionCdmPromise> caller_promise_; | 77 scoped_ptr<media::NewSessionCdmPromise> caller_promise_; |
86 base::Closure additional_resolve_cb_; | 78 base::Closure additional_resolve_cb_; |
87 }; | 79 }; |
88 | 80 |
89 scoped_ptr<PpapiDecryptor> PpapiDecryptor::Create( | 81 scoped_ptr<PpapiDecryptor> PpapiDecryptor::Create( |
90 const std::string& key_system, | 82 const std::string& key_system, |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
549 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 541 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
550 pepper_cdm_wrapper_.reset(); | 542 pepper_cdm_wrapper_.reset(); |
551 } | 543 } |
552 | 544 |
553 ContentDecryptorDelegate* PpapiDecryptor::CdmDelegate() { | 545 ContentDecryptorDelegate* PpapiDecryptor::CdmDelegate() { |
554 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 546 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
555 return (pepper_cdm_wrapper_) ? pepper_cdm_wrapper_->GetCdmDelegate() : NULL; | 547 return (pepper_cdm_wrapper_) ? pepper_cdm_wrapper_->GetCdmDelegate() : NULL; |
556 } | 548 } |
557 | 549 |
558 } // namespace content | 550 } // namespace content |
OLD | NEW |