summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/stream_crypto.h
blob: 4b60306b2dbca3e4688e6ba053b3ed67ef4139da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
 *  Copyright (C) 2017-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#ifndef C_API_ADDONINSTANCE_INPUTSTREAM_STREAMCRYPTO_H
#define C_API_ADDONINSTANCE_INPUTSTREAM_STREAMCRYPTO_H

#include <stdint.h>
#include <string.h>

#define STREAMCRYPTO_VERSION_LEVEL 2

#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */

  //============================================================================
  /// @defgroup cpp_kodi_addon_inputstream_Defs_StreamEncryption_STREAM_CRYPTO_KEY_SYSTEM enum STREAM_CRYPTO_KEY_SYSTEM
  /// @ingroup cpp_kodi_addon_inputstream_Defs_StreamEncryption
  /// @brief **Available ways to process stream cryptography**\n
  /// For @ref cpp_kodi_addon_inputstream_Defs_StreamEncryption_StreamCryptoSession,
  /// this defines the used and required auxiliary modules which are required to
  /// process the encryption stream.
  ///
  /// Used to set wanted [digital rights management](https://en.wikipedia.org/wiki/Digital_rights_management)
  /// (DRM) technology provider for stream.
  ///@{
  enum STREAM_CRYPTO_KEY_SYSTEM
  {
    /// @brief **0** - If no path is to be used, this is the default
    STREAM_CRYPTO_KEY_SYSTEM_NONE = 0,

    /// @brief **1** - To use [Widevine](https://en.wikipedia.org/wiki/Widevine) for processing
    STREAM_CRYPTO_KEY_SYSTEM_WIDEVINE,

    /// @brief **2** - To use [Playready](https://en.wikipedia.org/wiki/PlayReady) for processing
    STREAM_CRYPTO_KEY_SYSTEM_PLAYREADY,

    /// @brief **3** - To use Wiseplay for processing
    STREAM_CRYPTO_KEY_SYSTEM_WISEPLAY,

    /// @brief **4** - The maximum value to use in a list.
    STREAM_CRYPTO_KEY_SYSTEM_COUNT
  };
  ///@}
  //----------------------------------------------------------------------------

  //============================================================================
  /// @defgroup cpp_kodi_addon_inputstream_Defs_StreamEncryption_STREAM_CRYPTO_FLAGS enum STREAM_CRYPTO_FLAGS
  /// @ingroup cpp_kodi_addon_inputstream_Defs_StreamEncryption
  /// @brief **Cryptography flags to use special conditions**\n
  /// To identify special extra conditions.
  ///
  /// @note These variables are bit flags which are created using "|" can be used
  /// together.
  ///
  ///@{
  enum STREAM_CRYPTO_FLAGS
  {
    /// @brief **0000 0000** - Empty to set if nothing is used.
    STREAM_CRYPTO_FLAG_NONE = 0,

    /// @brief **0000 0001** - Is set in flags if decoding has to be done in
    /// [trusted execution environment (TEE)](https://en.wikipedia.org/wiki/Trusted_execution_environment).
    STREAM_CRYPTO_FLAG_SECURE_DECODER = (1 << 0)
  };
  ///@}
  //----------------------------------------------------------------------------

  //============================================================================
  /// @defgroup cpp_kodi_addon_inputstream_Defs_StreamEncryption_DEMUX_CRYPTO_INFO struct DEMUX_CRYPTO_INFO
  /// @ingroup cpp_kodi_addon_inputstream_Defs_StreamEncryption
  /// @brief **C data structure for processing encrypted streams.**\n
  /// If required, this structure is used for every DEMUX_PACKET to be processed.
  ///
  ///@{
  struct DEMUX_CRYPTO_INFO
  {
    /// @brief Number of subsamples.
    uint16_t numSubSamples;

    /// @brief Flags for later use.
    uint16_t flags;

    /// @brief @ref numSubSamples uint16_t's wich define the size of clear size
    /// of a subsample.
    uint16_t* clearBytes;

    /// @brief @ref numSubSamples uint32_t's wich define the size of cipher size
    /// of a subsample.
    uint32_t* cipherBytes;

    /// @brief Initialization vector
    uint8_t iv[16];

    /// @brief Key id
    uint8_t kid[16];
  };
  ///@}
  //----------------------------------------------------------------------------

  // Data to manage stream cryptography
  struct STREAM_CRYPTO_SESSION
  {
    // keysystem for encrypted media, STREAM_CRYPTO_KEY_SYSTEM_NONE for unencrypted
    // media.
    //
    // See STREAM_CRYPTO_KEY_SYSTEM for available options.
    enum STREAM_CRYPTO_KEY_SYSTEM keySystem;

    // Flags to use special conditions, see STREAM_CRYPTO_FLAGS for available flags.
    uint8_t flags;

    // The crypto session key id.
    char sessionId[256];
  };
  ///@}
  //----------------------------------------------------------------------------

#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */

#endif /* !C_API_ADDONINSTANCE_INPUTSTREAM_STREAMCRYPTO_H */