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/media/base/key_source.h"
13 #include "packager/media/base/status.h"
14 #include "packager/media/base/stream_info.h"
15 #include "packager/media/codecs/vpx_parser.h"
16 #include "packager/media/event/muxer_listener.h"
17 #include "packager/third_party/libwebm/src/mkvmuxer.hpp"
18 
19 namespace shaka {
20 namespace media {
21 
22 class AesCtrEncryptor;
23 class MediaSample;
24 
25 namespace webm {
26 
29 class Encryptor {
30  public:
31  Encryptor();
32  ~Encryptor();
33 
36  Status Initialize(MuxerListener* muxer_listener,
37  KeySource::TrackType track_type,
38  Codec codec,
39  KeySource* key_source,
40  bool webm_subsample_encryption);
41 
45  Status AddTrackInfo(mkvmuxer::Track* track);
46 
50  Status EncryptFrame(std::shared_ptr<MediaSample> sample, bool encrypt_frame);
51 
52  private:
53  // Create the encryptor for the internal encryption key.
54  Status CreateEncryptor(MuxerListener* muxer_listener,
55  KeySource::TrackType track_type,
56  Codec codec,
57  KeySource* key_source,
58  bool webm_subsample_encryption);
59 
60  private:
61  std::unique_ptr<EncryptionKey> key_;
62  std::unique_ptr<AesCtrEncryptor> encryptor_;
63  std::unique_ptr<VPxParser> vpx_parser_;
64 
65  DISALLOW_COPY_AND_ASSIGN(Encryptor);
66 };
67 
68 } // namespace webm
69 } // namespace media
70 } // namespace shaka
71 
72 #endif // MEDIA_FORMATS_WEBM_ENCRYPTOR_H_
Status AddTrackInfo(mkvmuxer::Track *track)
Definition: encryptor.cc:71
Status EncryptFrame(std::shared_ptr< MediaSample > sample, bool encrypt_frame)
Definition: encryptor.cc:76
Status Initialize(MuxerListener *muxer_listener, KeySource::TrackType track_type, Codec codec, KeySource *key_source, bool webm_subsample_encryption)
Definition: encryptor.cc:61
KeySource is responsible for encryption key acquisition.
Definition: key_source.h:30