Shaka Player Embedded
media_key_session.h
Go to the documentation of this file.
1 // Copyright 2017 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef SHAKA_EMBEDDED_JS_EME_MEDIA_KEY_SESSION_H_
16 #define SHAKA_EMBEDDED_JS_EME_MEDIA_KEY_SESSION_H_
17 
18 #include <functional>
19 #include <memory>
20 #include <mutex>
21 #include <string>
22 
26 
27 #include "src/debug/mutex.h"
33 #include "src/mapping/promise.h"
34 #include "src/memory/heap_tracer.h"
35 
36 namespace shaka {
37 namespace js {
38 namespace eme {
39 
41  DECLARE_TYPE_INFO(MediaKeySession);
42 
43  public:
45  std::shared_ptr<ImplementationFactory> factory,
46  std::shared_ptr<Implementation> implementation);
47 
48  void Trace(memory::HeapTracer* tracer) const override;
49 
50  std::string SessionId() const;
51 
53 
56 
59 
61  ByteBuffer init_data);
62  Promise Load(const std::string& session_id);
63  Promise Update(ByteBuffer response);
64  Promise Close();
65  Promise Remove();
66 
67  private:
68  mutable Mutex mutex_;
69  std::string session_id_;
70  const std::shared_ptr<ImplementationFactory> factory_;
71  const std::shared_ptr<Implementation> implementation_;
72  const MediaKeySessionType type_;
73  EmePromise closed_promise_;
74 };
75 
77  : public BackingObjectFactory<MediaKeySession, events::EventTarget> {
78  public:
80 };
81 
82 } // namespace eme
83 } // namespace js
84 } // namespace shaka
85 
86 #endif // SHAKA_EMBEDDED_JS_EME_MEDIA_KEY_SESSION_H_
virtual BackingObjectFactoryBase * factory() const =0
Promise GenerateRequest(MediaKeyInitDataType init_data_type, ByteBuffer init_data)
void Trace(memory::HeapTracer *tracer) const override
ExceptionOr< ReturnVal< JsValue > > GetKeyStatuses() const
ExceptionCode type
MediaKeySession(MediaKeySessionType type, std::shared_ptr< ImplementationFactory > factory, std::shared_ptr< Implementation > implementation)
Promise Load(const std::string &session_id)
ExceptionOr< double > GetExpiration() const
Promise Update(ByteBuffer response)
optional< Callback > Listener
Definition: event_target.h:46