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  CRYPTO_SESSION_SYSTEM_CLEARKEY,
24 };
25 
27 {
28  DemuxCryptoSession(const CryptoSessionSystem sys, const char* sData, const uint8_t flags)
29  : sessionId(sData), keySystem(sys), flags(flags)
30  {
31  }
32 
33  bool operator == (const DemuxCryptoSession &other) const
34  {
35  return keySystem == other.keySystem && sessionId == other.sessionId;
36  };
37 
38  // encryped stream infos
39  std::string sessionId;
40  CryptoSessionSystem keySystem;
41 
42  static const uint8_t FLAG_SECURE_DECODER = 1;
43  uint8_t flags;
44 private:
45  DemuxCryptoSession(const DemuxCryptoSession&) = delete;
46  DemuxCryptoSession& operator=(const DemuxCryptoSession&) = delete;
47 };
48 
49 //CryptoInfo stores the information to decrypt a sample
50 
52 {
53  explicit DemuxCryptoInfo(const unsigned int numSubs)
54  {
55  numSubSamples = numSubs;
56  flags = 0;
57  clearBytes = new uint16_t[numSubs];
58  cipherBytes = new uint32_t[numSubs];
59  };
60 
62  {
63  delete[] clearBytes;
64  delete[] cipherBytes;
65  }
66 
67 private:
68  DemuxCryptoInfo(const DemuxCryptoInfo&) = delete;
69  DemuxCryptoInfo& operator=(const DemuxCryptoInfo&) = delete;
70 };
Definition: stream_crypto.h:85
Definition: DemuxCrypto.h:26
Definition: DemuxCrypto.h:51