Shaka Player Embedded
media_encrypted_event.h
Go to the documentation of this file.
1 // Copyright 2018 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_EVENTS_MEDIA_ENCRYPTED_EVENT_H_
16 #define SHAKA_EMBEDDED_JS_EVENTS_MEDIA_ENCRYPTED_EVENT_H_
17 
18 #include <memory>
19 #include <string>
20 #include <utility>
21 
22 #include "shaka/optional.h"
24 #include "src/js/events/event.h"
27 #include "src/mapping/struct.h"
28 
29 namespace shaka {
30 namespace js {
31 namespace events {
32 
35 
37  ADD_DICT_FIELD(initData, ByteBuffer);
38 };
39 
40 
44 class MediaEncryptedEvent final : public Event {
46 
47  public:
48  MediaEncryptedEvent(EventType event_type,
49  eme::MediaKeyInitDataType init_data_type,
50  ByteBuffer init_data);
51 
53  const std::string& event_type,
55  if (init_data.has_value()) {
56  return new MediaEncryptedEvent(event_type, init_data->initDataType,
57  std::move(init_data->initData));
58  } else {
59  return new MediaEncryptedEvent(
61  }
62  }
63 
64  void Trace(memory::HeapTracer* tracer) const override;
65 
68 
69  private:
70  MediaEncryptedEvent(const std::string& event_type,
71  eme::MediaKeyInitDataType init_data_type,
72  ByteBuffer init_data);
73 };
74 
76  : public BackingObjectFactory<MediaEncryptedEvent, Event> {
77  public:
79 };
80 
81 } // namespace events
82 } // namespace js
83 } // namespace shaka
84 
85 #endif // SHAKA_EMBEDDED_JS_EVENTS_MEDIA_ENCRYPTED_EVENT_H_
DECLARE_STRUCT_SPECIAL_METHODS_MOVE_ONLY(MediaEncryptedEventInit)
static MediaEncryptedEvent * Create(const std::string &event_type, optional< MediaEncryptedEventInit > init_data)
const eme::MediaKeyInitDataType init_data_type
void Trace(memory::HeapTracer *tracer) const override
Definition: struct.cc:49
#define DECLARE_TYPE_INFO(type)
ADD_DICT_FIELD(initDataType, eme::MediaKeyInitDataType)
bool has_value() const
Definition: optional.h:143