summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Stream.h
blob: 5613947059b6b3136893a617f1d1b05d91e5d505 (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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
/*
 *  Copyright (C) 2005-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.
 */

#pragma once

#include "../../AddonBase.h"
#include "../../c-api/addon-instance/pvr/pvr_stream.h"

//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
// "C++" Definitions group 9 - PVR stream definitions (NOTE: Becomes replaced
// in future by inputstream addon instance way)

#ifdef __cplusplus

namespace kodi
{
namespace addon
{

//==============================================================================
/// @defgroup cpp_kodi_addon_pvr_Defs_Stream_PVRCodec class PVRCodec
/// @ingroup cpp_kodi_addon_pvr_Defs_Stream
/// @brief **PVR codec identifier**\n
/// Used to exchange the desired codec type between Kodi and addon.
///
/// @ref kodi::addon::CInstancePVRClient::GetCodecByName is used to get this data.
///
/// ----------------------------------------------------------------------------
///
/// @copydetails cpp_kodi_addon_pvr_Defs_Stream_PVRCodec_Help
///
///@{
class PVRCodec : public CStructHdl<PVRCodec, PVR_CODEC>
{
  friend class CInstancePVRClient;

public:
  /*! \cond PRIVATE */
  PVRCodec()
  {
    m_cStructure->codec_type = PVR_CODEC_TYPE_UNKNOWN;
    m_cStructure->codec_id = PVR_INVALID_CODEC_ID;
  }
  PVRCodec(const PVRCodec& type) : CStructHdl(type) {}
  /*! \endcond */

  /// @defgroup cpp_kodi_addon_pvr_Defs_Stream_PVRCodec_Help Value Help
  /// @ingroup cpp_kodi_addon_pvr_Defs_Stream_PVRCodec
  ///
  /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_Stream_PVRCodec :</b>
  /// | Name | Type | Set call | Get call
  /// |------|------|----------|----------
  /// | **Codec type** | @ref PVR_CODEC_TYPE | @ref PVRCodec::SetCodecType "SetCodecType" | @ref PVRCodec::GetCodecType "GetCodecType"
  /// | **Codec identifier** | `unsigned int` | @ref PVRCodec::SetCodecId "SetCodecId" | @ref PVRCodec::GetCodecId "GetCodecId"
  ///

  /// @addtogroup cpp_kodi_addon_pvr_Defs_Stream_PVRCodec
  ///@{

  /// @brief Codec type.
  void SetCodecType(PVR_CODEC_TYPE codecType) { m_cStructure->codec_type = codecType; }

  /// @brief To get with @ref SetCodecType() changed values.
  PVR_CODEC_TYPE GetCodecType() const { return m_cStructure->codec_type; }

  /// @brief Codec id.
  ///
  /// Related codec identifier, normally match the ffmpeg id's.
  void SetCodecId(unsigned int codecId) { m_cStructure->codec_id = codecId; }

  /// @brief To get with @ref SetCodecId() changed values.
  unsigned int GetCodecId() const { return m_cStructure->codec_id; }
  ///@}

private:
  PVRCodec(const PVR_CODEC& type) : CStructHdl(&type) {}
  PVRCodec(const PVR_CODEC* type) : CStructHdl(type) {}
  PVRCodec(PVR_CODEC* type) : CStructHdl(type) {}
};
///@}
//------------------------------------------------------------------------------

//==============================================================================
/// @defgroup cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties class PVRStreamProperties
/// @ingroup cpp_kodi_addon_pvr_Defs_Stream
/// @brief **PVR stream properties**\n
/// All information about a respective stream is stored in this, so that Kodi
/// can process the data given by the addon after demux.
///
/// ----------------------------------------------------------------------------
///
/// @copydetails cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties_Help
///
///@{
class PVRStreamProperties
  : public CStructHdl<PVRStreamProperties, PVR_STREAM_PROPERTIES::PVR_STREAM>
{
  friend class CInstancePVRClient;

public:
  /*! \cond PRIVATE */
  PVRStreamProperties() { memset(m_cStructure, 0, sizeof(PVR_STREAM_PROPERTIES::PVR_STREAM)); }
  PVRStreamProperties(const PVRStreamProperties& type) : CStructHdl(type) {}
  /*! \endcond */

  /// @defgroup cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties_Help Value Help
  /// @ingroup cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties
  /// ----------------------------------------------------------------------------
  ///
  /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties :</b>
  /// | Name | Type | Set call | Get call
  /// |------|------|----------|----------
  /// | **PID** | `unsigned int` | @ref PVRStreamProperties::SetPID "SetPID" | @ref PVRStreamProperties::GetPID "GetPID"
  /// | **Codec type** | @ref PVR_CODEC_TYPE | @ref PVRStreamProperties::SetCodecType "SetCodecType" | @ref PVRStreamProperties::GetCodecType "GetCodecType"
  /// | **Codec identifier** | `unsigned int` | @ref PVRStreamProperties::SetCodecId "SetCodecId" | @ref PVRStreamProperties::GetCodecId "GetCodecId"
  /// | **Language** | `std::string` | @ref PVRStreamProperties::SetLanguage "SetLanguage" | @ref PVRStreamProperties::GetLanguage "GetLanguage"
  /// | **Subtitle info** | `int` | @ref PVRStreamProperties::SetSubtitleInfo "SetSubtitleInfo" | @ref PVRStreamProperties::GetSubtitleInfo "GetSubtitleInfo"
  /// | **FPS scale** | `int` | @ref PVRStreamProperties::SetFPSScale "SetFPSScale" | @ref PVRStreamProperties::GetFPSScale "GetFPSScale"
  /// | **FPS rate** | `int` | @ref PVRStreamProperties::SetFPSRate "SetFPSRate" | @ref PVRStreamProperties::GetFPSRate "GetFPSRate"
  /// | **Height** | `int` | @ref PVRStreamProperties::SetHeight "SetHeight" | @ref PVRStreamProperties::GetHeight "GetHeight"
  /// | **Width** | `int` | @ref PVRStreamProperties::SetWidth "SetWidth" | @ref PVRStreamProperties::GetWidth "GetWidth"
  /// | **Aspect ratio** | `float` | @ref PVRStreamProperties::SetAspect "SetAspect" | @ref PVRStreamProperties::GetAspect "GetAspect"
  /// | **Channels** | `int` | @ref PVRStreamProperties::SetChannels "SetChannels" | @ref PVRStreamProperties::GetChannels "GetChannels"
  /// | **Samplerate** | `int` | @ref PVRStreamProperties::SetSampleRate "SetSampleRate" | @ref PVRStreamProperties::GetSampleRate "GetSampleRate"
  /// | **Block align** | `int` | @ref PVRStreamProperties::SetBlockAlign "SetBlockAlign" | @ref PVRStreamProperties::GetBlockAlign "GetBlockAlign"
  /// | **Bit rate** | `int` | @ref PVRStreamProperties::SetBitRate "SetBitRate" | @ref PVRStreamProperties::GetBitRate "GetBitRate"
  /// | **Bits per sample** | `int` | @ref PVRStreamProperties::SetBitsPerSample "SetBitsPerSample" | @ref PVRStreamProperties::GetBitsPerSample "GetBitsPerSample"
  ///

  /// @addtogroup cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties
  ///@{

  /// @brief PID.
  void SetPID(unsigned int pid) { m_cStructure->iPID = pid; }

  /// @brief To get with @ref SetPID() changed values.
  unsigned int GetPID() const { return m_cStructure->iPID; }

  /// @brief Codec type this stream.
  void SetCodecType(PVR_CODEC_TYPE codecType) { m_cStructure->iCodecType = codecType; }

  /// @brief To get with @ref SetCodecType() changed values.
  PVR_CODEC_TYPE GetCodecType() const { return m_cStructure->iCodecType; }

  /// @brief Codec id of this stream.
  void SetCodecId(unsigned int codecId) { m_cStructure->iCodecId = codecId; }

  /// @brief To get with @ref SetCodecId() changed values.
  unsigned int GetCodecId() const { return m_cStructure->iCodecId; }

  /// @brief 3 letter language id.
  void SetLanguage(const std::string& language)
  {
    if (language.size() > 3)
    {
      kodi::Log(ADDON_LOG_ERROR,
                "PVRStreamProperties::%s: Language string size '%li' higher as needed 3", __func__,
                language.size());
      return;
    }
    m_cStructure->strLanguage[0] = language[0];
    m_cStructure->strLanguage[1] = language[1];
    m_cStructure->strLanguage[2] = language[2];
    m_cStructure->strLanguage[2] = 0;
  }

  /// @brief To get with @ref SetLanguage() changed values.
  std::string GetLanguage() const { return m_cStructure->strLanguage; }

  /// @brief Subtitle Info
  void SetSubtitleInfo(int subtitleInfo) { m_cStructure->iSubtitleInfo = subtitleInfo; }

  /// @brief To get with @ref SetSubtitleInfo() changed values.
  int GetSubtitleInfo() const { return m_cStructure->iSubtitleInfo; }

  /// @brief To set scale of 1000 and a rate of 29970 will result in 29.97 fps.
  void SetFPSScale(int fpsScale) { m_cStructure->iFPSScale = fpsScale; }

  /// @brief To get with @ref SetFPSScale() changed values.
  int GetFPSScale() const { return m_cStructure->iFPSScale; }

  /// @brief FPS rate
  void SetFPSRate(int fpsRate) { m_cStructure->iFPSRate = fpsRate; }

  /// @brief To get with @ref SetFPSRate() changed values.
  int GetFPSRate() const { return m_cStructure->iFPSRate; }

  /// @brief Height of the stream reported by the demuxer
  void SetHeight(int height) { m_cStructure->iHeight = height; }

  /// @brief To get with @ref SetHeight() changed values.
  int GetHeight() const { return m_cStructure->iHeight; }

  /// @brief Width of the stream reported by the demuxer.
  void SetWidth(int width) { m_cStructure->iWidth = width; }

  /// @brief To get with @ref SetWidth() changed values.
  int GetWidth() const { return m_cStructure->iWidth; }

  /// @brief Display aspect ratio of the stream.
  void SetAspect(float aspect) { m_cStructure->fAspect = aspect; }

  /// @brief To get with @ref SetAspect() changed values.
  float GetAspect() const { return m_cStructure->fAspect; }

  /// @brief Amount of channels.
  void SetChannels(int channels) { m_cStructure->iChannels = channels; }

  /// @brief To get with @ref SetChannels() changed values.
  int GetChannels() const { return m_cStructure->iChannels; }

  /// @brief Sample rate.
  void SetSampleRate(int sampleRate) { m_cStructure->iSampleRate = sampleRate; }

  /// @brief To get with @ref SetSampleRate() changed values.
  int GetSampleRate() const { return m_cStructure->iSampleRate; }

  /// @brief Block alignment
  void SetBlockAlign(int blockAlign) { m_cStructure->iBlockAlign = blockAlign; }

  /// @brief To get with @ref SetBlockAlign() changed values.
  int GetBlockAlign() const { return m_cStructure->iBlockAlign; }

  /// @brief Bit rate.
  void SetBitRate(int bitRate) { m_cStructure->iBitRate = bitRate; }

  /// @brief To get with @ref SetBitRate() changed values.
  int GetBitRate() const { return m_cStructure->iBitRate; }

  /// @brief Bits per sample.
  void SetBitsPerSample(int bitsPerSample) { m_cStructure->iBitsPerSample = bitsPerSample; }

  /// @brief To get with @ref SetBitsPerSample() changed values.
  int GetBitsPerSample() const { return m_cStructure->iBitsPerSample; }
  ///@}

private:
  PVRStreamProperties(const PVR_STREAM_PROPERTIES::PVR_STREAM* type) : CStructHdl(type) {}
  PVRStreamProperties(PVR_STREAM_PROPERTIES::PVR_STREAM* type) : CStructHdl(type) {}
};
///@}
//------------------------------------------------------------------------------

//==============================================================================
/// @defgroup cpp_kodi_addon_pvr_Defs_Stream_PVRStreamTimes class PVRStreamTimes
/// @ingroup cpp_kodi_addon_pvr_Defs_Stream
/// @brief **Times of playing stream (Live TV and recordings)**\n
/// This class is used to transfer the necessary data when
/// @ref kodi::addon::PVRStreamProperties::GetStreamTimes is called.
///
/// ----------------------------------------------------------------------------
///
/// @copydetails cpp_kodi_addon_pvr_Defs_Stream_PVRStreamTimes_Help
///
///@{
class PVRStreamTimes : public CStructHdl<PVRStreamTimes, PVR_STREAM_TIMES>
{
  friend class CInstancePVRClient;

public:
  /*! \cond PRIVATE */
  PVRStreamTimes() { memset(m_cStructure, 0, sizeof(PVR_STREAM_TIMES)); }
  PVRStreamTimes(const PVRStreamTimes& type) : CStructHdl(type) {}
  /*! \endcond */

  /// @defgroup cpp_kodi_addon_pvr_Defs_Stream_PVRStreamTimes_Help Value Help
  /// @ingroup cpp_kodi_addon_pvr_Defs_Stream_PVRStreamTimes
  /// ----------------------------------------------------------------------------
  ///
  /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_Stream_PVRStreamTimes :</b>
  /// | Name | Type | Set call | Get call
  /// |------|------|----------|----------
  /// | **Start time** | `time_t` | @ref PVRStreamTimes::SetStartTime "SetStartTime" | @ref PVRStreamTimes::GetStartTime "GetStartTime"
  /// | **PTS start** | `int64_t` | @ref PVRStreamTimes::SetPTSStart "SetPTSStart" | @ref PVRStreamTimes::GetPTSStart "GetPTSStart"
  /// | **PTS begin** | `int64_t` | @ref PVRStreamTimes::SetPTSBegin "SetPTSBegin" | @ref PVRStreamTimes::GetPTSBegin "GetPTSBegin"
  /// | **PTS end** | `int64_t` | @ref PVRStreamTimes::SetPTSEnd "SetPTSEnd" | @ref PVRStreamTimes::GetPTSEnd "GetPTSEnd"
  ///

  /// @addtogroup cpp_kodi_addon_pvr_Defs_Stream_PVRStreamTimes
  ///@{

  /// @brief For recordings, this must be zero. For Live TV, this is a reference
  /// time in units of time_t (UTC) from which time elapsed starts. Ideally start
  /// of tv show, but can be any other value.
  void SetStartTime(time_t startTime) { m_cStructure->startTime = startTime; }

  /// @brief To get with @ref SetStartTime() changed values.
  time_t GetStartTime() const { return m_cStructure->startTime; }

  /// @brief The pts of startTime.
  void SetPTSStart(int64_t ptsStart) { m_cStructure->ptsStart = ptsStart; }

  /// @brief To get with @ref SetPTSStart() changed values.
  int64_t GetPTSStart() const { return m_cStructure->ptsStart; }

  /// @brief Earliest pts player can seek back. Value is in micro seconds,
  /// relative to PTS start. For recordings, this must be zero. For Live TV, this
  /// must be zero if not timeshifting and must point to begin of the timeshift
  /// buffer, otherwise.
  void SetPTSBegin(int64_t ptsBegin) { m_cStructure->ptsBegin = ptsBegin; }

  /// @brief To get with @ref SetPTSBegin() changed values.
  int64_t GetPTSBegin() const { return m_cStructure->ptsBegin; }

  /// @brief Latest pts player can seek forward. Value is in micro seconds,
  /// relative to PTS start. For recordings, this must be the total length. For
  /// Live TV, this must be zero if not timeshifting and must point to end of
  /// the timeshift buffer, otherwise.
  void SetPTSEnd(int64_t ptsEnd) { m_cStructure->ptsEnd = ptsEnd; }

  /// @brief To get with @ref SetPTSEnd() changed values.
  int64_t GetPTSEnd() const { return m_cStructure->ptsEnd; }
  ///@}

private:
  PVRStreamTimes(const PVR_STREAM_TIMES* type) : CStructHdl(type) {}
  PVRStreamTimes(PVR_STREAM_TIMES* type) : CStructHdl(type) {}
};
///@}
//------------------------------------------------------------------------------

} /* namespace addon */
} /* namespace kodi */

#endif /* __cplusplus */