Twitch SDK (Internal)
coretypes.h
Go to the documentation of this file.
1 /********************************************************************************************
2 * Twitch Broadcasting SDK
3 *
4 * This software is supplied under the terms of a license agreement with Twitch Interactive, Inc. and
5 * may not be copied or used except in accordance with the terms of that agreement
6 * Copyright (c) 2012-2016 Twitch Interactive, Inc.
7 *********************************************************************************************/
8 
9 #pragma once
10 
11 #include <stdint.h>
12 #include <string>
13 #include <vector>
14 
15 #define UNUSED(x) (void)x;
16 
17 
18 typedef unsigned int uint;
19 
20 namespace ttv
21 {
22  using UserId = uint32_t;
23  using ChannelId = uint32_t;
24  using GameId = uint32_t;
25 
26  // Represents an absolute time in seconds since epoch.
27  using Timestamp = uint32_t;
28  using Color = uint32_t;
29  using BroadcastId = uint32_t;
30 
31 
32  struct UserInfo
33  {
34  UserInfo();
35 
36  bool operator==(const UserInfo& other) const;
37  bool operator!=(const UserInfo& other) const;
38 
39  std::string userName;
40  std::string displayName;
41  std::string bio;
42  std::string logoImageUrl;
45  };
46 
47  enum class BroadcasterType
48  {
49  Partner,
50  Affiliate,
51  None,
52  Unknown
53  };
54 
58  struct ChannelInfo
59  {
60  ChannelInfo();
61 
62  std::string displayName;
63  std::string name;
64  std::string game;
65  std::string description;
66  std::string status;
67  std::string language;
68  std::string broadcasterLanguage;
69  std::string logoImageUrl;
70  std::string channelUrl;
71  std::string videoBannerImageUrl;
72  std::string profileBannerImageUrl;
73 
78  uint32_t numFollowers;
79  uint32_t numViews;
80 
82  bool mature;
83  bool partner;
84  };
85 
90  {
91  std::string largeUrl;
92  std::string mediumUrl;
93  std::string smallUrl;
94  std::string templateUrl;
95  };
96 
100  enum class BroadcastPlatform
101  {
102  WatchParty,
103  Premiere,
104  Rerun,
105  Playlist,
106  Mobile,
107  Xbox,
108  PS4,
109  Live,
110  Unknown
111  };
112 
117  enum class StreamType
118  {
119  WatchParty,
120  Premiere,
121  Rerun,
122  Playlist,
123  Live,
124  Unknown
125  };
126 
130  struct StreamInfo
131  {
132  StreamInfo();
133 
134  // channelInfo.broadcasterType will always be None - https://jira.twitch.com/browse/AML-2538
137  std::vector<std::string> communityIds;
138  std::string game;
139 
140  double averageFPS;
141  uint64_t streamId;
142  uint64_t delay;
143  uint64_t viewerCount;
144  uint32_t videoHeight;
146 
150  };
151 
152  enum class PubSubState
153  {
154  Disconnected,
155  Connecting,
156  Connected,
158  };
159 
163  enum class VodStatus
164  {
165  Recording,
166  Recorded,
167  Unknown
168 
169  };
170 
174  enum class VodType
175  {
176  Highlight,
177  Archive,
178  Upload,
179  Unknown
180  };
181 
186  {
188 
189  std::string incrementUrl;
190  std::string vodId;
191  std::string title;
192  std::string watchPartyId;
194  bool viewable;
195  };
196 
201  {
202  std::string url;
203  std::string format;
204  uint32_t width;
205  uint32_t height;
206  };
207 
212  {
213  public:
217  enum class Type
218  {
219  Null,
220  Boolean,
221  Integer,
222  Double,
223  String
224  };
225 
229  TrackingValue();
230  TrackingValue(std::nullptr_t value);
231 
235  TrackingValue(bool value);
236 
240  TrackingValue(int64_t value);
241  TrackingValue(uint32_t value);
242  TrackingValue(int value);
243 
247  TrackingValue(double value);
248 
252  TrackingValue(const std::string& value);
253  TrackingValue(std::string&& value);
254  TrackingValue(const char* value);
255 
256  TrackingValue(const TrackingValue& src);
258 
259  ~TrackingValue();
260 
261  TrackingValue& operator=(const TrackingValue& src);
262  TrackingValue& operator=(TrackingValue&& src);
263 
267  Type GetType() const { return mType; }
268 
274  bool GetBooleanValue() const;
275  int64_t GetIntegerValue() const;
276  double GetDoubleValue() const;
277  std::string GetStringValue() const;
278 
279  private:
280  union Value
281  {
282  Value() {}
283  ~Value() {}
284 
285  bool asBool;
286  int64_t asInteger;
287  double asDouble;
288  std::string asString;
289  } mValue;
290 
292  };
293 }
uint32_t UserId
Definition: coretypes.h:22
BroadcasterType
Definition: coretypes.h:47
uint32_t numViews
Definition: coretypes.h:79
uint64_t delay
Definition: coretypes.h:142
VodType
Definition: coretypes.h:174
PreviewImages previewImages
Definition: coretypes.h:136
VodType broadcastType
The type of vod being played.
Definition: coretypes.h:193
bool operator==(const UserInfo &other) const
uint32_t BroadcastId
Definition: coretypes.h:29
std::string incrementUrl
The URL to increment whenever a new VOD is played.
Definition: coretypes.h:189
uint64_t viewerCount
Definition: coretypes.h:143
std::string url
The URL of the profile image.
Definition: coretypes.h:202
std::string logoImageUrl
Definition: coretypes.h:42
StreamType
Definition: coretypes.h:117
uint32_t height
Height of the profile image.
Definition: coretypes.h:205
Definition: coretypes.h:32
Color profileBannerBackgroundColor
By default set to 0xFF000000.
Definition: coretypes.h:75
bool mature
Definition: coretypes.h:82
std::string displayName
Definition: coretypes.h:62
uint32_t GameId
Definition: coretypes.h:24
std::string logoImageUrl
Definition: coretypes.h:69
ChannelId channelId
Definition: coretypes.h:74
std::string asString
Definition: coretypes.h:288
uint32_t videoHeight
Definition: coretypes.h:144
uint32_t Timestamp
Definition: coretypes.h:27
std::string game
Definition: coretypes.h:138
std::string game
Definition: coretypes.h:64
Definition: coretypes.h:130
BroadcasterType broadcasterType
Definition: coretypes.h:81
Timestamp createdAtTimestamp
Definition: coretypes.h:145
VodStatus
Definition: coretypes.h:163
bool asBool
Definition: coretypes.h:285
Type
Definition: coretypes.h:217
std::string broadcasterLanguage
Definition: coretypes.h:68
JSON (JavaScript Object Notation).
Definition: adsapi.h:16
std::string userName
Definition: coretypes.h:39
If neither Partner nor Affiliate.
StreamType streamType
Definition: coretypes.h:148
std::string videoBannerImageUrl
Definition: coretypes.h:71
The VOD is still being recorded and the stream is live.
std::string description
Definition: coretypes.h:65
std::string status
Definition: coretypes.h:66
Definition: coretypes.h:89
std::string largeUrl
Definition: coretypes.h:91
Timestamp createdTimestamp
Definition: coretypes.h:44
std::string templateUrl
Definition: coretypes.h:94
BroadcastPlatform broadcastPlatform
Definition: coretypes.h:147
uint32_t width
Width of the profile image.
Definition: coretypes.h:204
int64_t asInteger
Definition: coretypes.h:286
std::string title
The title of the currently playing VOD.
Definition: coretypes.h:191
Definition: coretypes.h:200
uint64_t streamId
Definition: coretypes.h:141
PubSubState
Definition: coretypes.h:152
std::string displayName
Definition: coretypes.h:40
Definition: coretypes.h:211
unsigned int uint
Definition: coretypes.h:18
bool operator!=(const UserInfo &other) const
UserId userId
Definition: coretypes.h:43
bool isPlaylist
Definition: coretypes.h:149
std::string vodId
The currently playing VOD ID.
Definition: coretypes.h:190
std::string format
The filetype/format of the profile image.
Definition: coretypes.h:203
std::string profileBannerImageUrl
Definition: coretypes.h:72
std::string language
Definition: coretypes.h:67
std::vector< std::string > communityIds
Definition: coretypes.h:137
Value()
Definition: coretypes.h:282
bool viewable
Marked true if this VOD is published and available for anyone to view, false if it is not...
Definition: coretypes.h:194
ChannelInfo channelInfo
Definition: coretypes.h:135
Timestamp updatedAtTimestamp
Definition: coretypes.h:77
Definition: coretypes.h:280
Type GetType() const
Definition: coretypes.h:267
double asDouble
Definition: coretypes.h:287
std::string smallUrl
Definition: coretypes.h:93
std::string name
Definition: coretypes.h:63
bool partner
Definition: coretypes.h:83
std::string watchPartyId
The unique ID for this watch party (should be the same across all VODs)
Definition: coretypes.h:192
Definition: coretypes.h:185
Timestamp createdAtTimestamp
Definition: coretypes.h:76
uint32_t ChannelId
Definition: coretypes.h:23
Definition: coretypes.h:58
Type mType
Definition: coretypes.h:291
~Value()
Definition: coretypes.h:283
BroadcastPlatform
Definition: coretypes.h:100
std::string mediumUrl
Definition: coretypes.h:92
std::string bio
Definition: coretypes.h:41
uint32_t Color
Definition: coretypes.h:28
double averageFPS
Definition: coretypes.h:140
std::string channelUrl
Definition: coretypes.h:70
uint32_t numFollowers
Definition: coretypes.h:78