DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
encryptor.h
1 // Copyright 2015 Google Inc. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file or at
5 // https://developers.google.com/open-source/licenses/bsd
6 
7 #ifndef MEDIA_FORMATS_WEBM_ENCRYPTOR_H_
8 #define MEDIA_FORMATS_WEBM_ENCRYPTOR_H_
9 
10 #include <memory>
11 #include "packager/base/macros.h"
12 #include "packager/base/memory/ref_counted.h"
13 #include "packager/media/base/key_source.h"
14 #include "packager/media/base/status.h"
15 #include "packager/media/base/stream_info.h"
16 #include "packager/media/codecs/vpx_parser.h"
17 #include "packager/media/event/muxer_listener.h"
18 #include "packager/third_party/libwebm/src/mkvmuxer.hpp"
19 
20 namespace shaka {
21 namespace media {
22 
23 class AesCtrEncryptor;
24 class MediaSample;
25 
26 namespace webm {
27 
30 class Encryptor {
31  public:
32  Encryptor();
33  ~Encryptor();
34 
37  Status Initialize(MuxerListener* muxer_listener,
38  KeySource::TrackType track_type,
39  Codec codec,
40  KeySource* key_source,
41  bool webm_subsample_encryption);
42 
46  Status AddTrackInfo(mkvmuxer::Track* track);
47 
51  Status EncryptFrame(scoped_refptr<MediaSample> sample,
52  bool encrypt_frame);
53 
54  private:
55  // Create the encryptor for the internal encryption key.
56  Status CreateEncryptor(MuxerListener* muxer_listener,
57  KeySource::TrackType track_type,
58  Codec codec,
59  KeySource* key_source,
60  bool webm_subsample_encryption);
61 
62  private:
63  std::unique_ptr<EncryptionKey> key_;
64  std::unique_ptr<AesCtrEncryptor> encryptor_;
65  std::unique_ptr<VPxParser> vpx_parser_;
66 
67  DISALLOW_COPY_AND_ASSIGN(Encryptor);
68 };
69 
70 } // namespace webm
71 } // namespace media
72 } // namespace shaka
73 
74 #endif // MEDIA_FORMATS_WEBM_ENCRYPTOR_H_
Status AddTrackInfo(mkvmuxer::Track *track)
Definition: encryptor.cc:71
Status Initialize(MuxerListener *muxer_listener, KeySource::TrackType track_type, Codec codec, KeySource *key_source, bool webm_subsample_encryption)
Definition: encryptor.cc:61
Status EncryptFrame(scoped_refptr< MediaSample > sample, bool encrypt_frame)
Definition: encryptor.cc:76
KeySource is responsible for encryption key acquisition.
Definition: key_source.h:30