xbmc
DemuxCrypto.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/stream_crypto.h"
12 
13 #include <string>
14 
15 //CryptoSession is usually obtained once per stream, but could change if an key expires
16 
17 enum CryptoSessionSystem : uint8_t
18 {
19  CRYPTO_SESSION_SYSTEM_NONE,
20  CRYPTO_SESSION_SYSTEM_WIDEVINE,
21  CRYPTO_SESSION_SYSTEM_PLAYREADY,
22  CRYPTO_SESSION_SYSTEM_WISEPLAY,
23 };
24 
26 {
27  DemuxCryptoSession(const CryptoSessionSystem sys, const char* sData, const uint8_t flags)
28  : sessionId(sData), keySystem(sys), flags(flags)
29  {
30  }
31 
32  bool operator == (const DemuxCryptoSession &other) const
33  {
34  return keySystem == other.keySystem && sessionId == other.sessionId;
35  };
36 
37  // encryped stream infos
38  std::string sessionId;
39  CryptoSessionSystem keySystem;
40 
41  static const uint8_t FLAG_SECURE_DECODER = 1;
42  uint8_t flags;
43 private:
44  DemuxCryptoSession(const DemuxCryptoSession&) = delete;
45  DemuxCryptoSession& operator=(const DemuxCryptoSession&) = delete;
46 };
47 
48 //CryptoInfo stores the information to decrypt a sample
49 
51 {
52  explicit DemuxCryptoInfo(const unsigned int numSubs)
53  {
54  numSubSamples = numSubs;
55  flags = 0;
56  clearBytes = new uint16_t[numSubs];
57  cipherBytes = new uint32_t[numSubs];
58  };
59 
61  {
62  delete[] clearBytes;
63  delete[] cipherBytes;
64  }
65 
66 private:
67  DemuxCryptoInfo(const DemuxCryptoInfo&) = delete;
68  DemuxCryptoInfo& operator=(const DemuxCryptoInfo&) = delete;
69 };
Definition: stream_crypto.h:82
Definition: DemuxCrypto.h:25
Definition: DemuxCrypto.h:50