NVIDIAGeForceExperienceSDK
ihighlights_cpp_impl.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
2 *
3 * NVIDIA CORPORATION and its licensors retain all intellectual property
4 * and proprietary rights in and to this software, related documentation
5 * and any modifications thereto. Any use, reproduction, disclosure or
6 * distribution of this software and related documentation without an express
7 * license agreement from NVIDIA CORPORATION is strictly prohibited.
8 */
9 
16 #ifndef GFESDK_IHIGHLIGHTS_CPP_IMPL_H
17 #define GFESDK_IHIGHLIGHTS_CPP_IMPL_H
18 
19 #include "ihighlights_cpp.h"
21 
22 #include <memory>
23 
24 namespace GfeSDK
25 {
26 class HighlightsImpl : public Highlights
27 {
28 public:
30  virtual void ConfigureAsync(HighlightConfigParams const& params, TCallback cb = nullptr, void* cbContext = nullptr);
32  virtual void GetUserSettingsAsync(TGetUserSettingsCallback cb = nullptr, void* cbContext = nullptr) const;
34  virtual void OpenGroupAsync(HighlightOpenGroupParams const& params, TCallback cb = nullptr, void* cbContext = nullptr);
36  virtual void CloseGroupAsync(HighlightCloseGroupParams const& params, TCallback cb = nullptr, void* cbContext = nullptr);
38  virtual void SetScreenshotHighlightAsync(ScreenshotHighlightParams const& params, TCallback cb = nullptr, void* cbContext = nullptr);
40  virtual void SetVideoHighlightAsync(VideoHighlightParams const& params, TCallback cb = nullptr, void* cbContext = nullptr);
42  virtual void OpenSummaryAsync(SummaryParams const& params, TCallback cb = nullptr, void* cbContext = nullptr);
44  virtual void GetNumberOfHighlightsAsync(GroupView const& params, TGetNumberOfHighlightsCallback cb = nullptr, void* cbContext = nullptr);
45 
46  friend class Highlights;
47 private:
48  // Remove default construct, copy and assignment operators
49  HighlightsImpl(Core* core) : m_handle(core ? core->GetHandle() : nullptr) {}
50  HighlightsImpl(const HighlightsImpl& other) {}
51  HighlightsImpl& operator=(const HighlightsImpl& other) {}
52 
53 private:
54  NVGSDK_HANDLE* m_handle;
55 };
56 
57 inline Highlights* Highlights::Create(Core* core)
58 {
59  return new HighlightsImpl(core);
60 }
61 
62 inline void HighlightsImpl::ConfigureAsync(HighlightConfigParams const& params, TCallback callback, void* context)
63 {
65  std::vector<NVGSDK_Highlight> cHighlights;
66  std::vector<std::vector<NVGSDK_LocalizedPair>> cLocaleMaps;
67  for (auto it = params.highlightDefinitions.begin(); it != params.highlightDefinitions.end(); ++it)
68  {
69  cLocaleMaps.push_back(std::vector<NVGSDK_LocalizedPair>());
70  for (auto localeIt = it->nameLocaleTable.begin(); localeIt != it->nameLocaleTable.end(); ++localeIt)
71  {
72  cLocaleMaps.back().push_back({
73  localeIt->first.c_str(),
74  localeIt->second.c_str()
75  });
76  }
77  cHighlights.push_back({
78  it->id.c_str(),
79  it->userDefaultInterest,
80  it->highlightTags,
81  it->significance,
82  &cLocaleMaps.back()[0],
83  it->nameLocaleTable.size()
84  });
85  }
86  cParams.highlightDefinitionTable = &cHighlights[0];
87  cParams.highlightTableSize = cHighlights.size();
88  cParams.defaultLocale = params.defaultLocale.c_str();
89  NVGSDK_Highlights_ConfigureAsync(m_handle, &cParams, CoreImpl::callbackWrapper, new CoreImpl::CallbackContext<TCallback>({ callback, context }));
90 }
91 
92 inline void HighlightsImpl::GetUserSettingsAsync(TGetUserSettingsCallback callback, void* context) const
93 {
94  NVGSDK_Highlights_GetUserSettingsAsync(m_handle, [](NVGSDK_RetCode rc, NVGSDK_Highlights_UserSettings const* data, void* context) {
95  std::unique_ptr<CoreImpl::CallbackContext<TGetUserSettingsCallback>> callbackContext(reinterpret_cast<CoreImpl::CallbackContext<TGetUserSettingsCallback>*>(context));
96  if (!callbackContext->callback) return;
97 
98  if (NVGSDK_FAILED(rc))
99  {
100  return callbackContext->callback(rc, nullptr, callbackContext->appContext);
101  }
102 
104  for (size_t i = 0; i < data->highlightSettingTableSize; ++i)
105  {
106  r.highlightSettings.push_back({
107  data->highlightSettingTable[i].id,
108  data->highlightSettingTable[i].enabled
109  });
110  }
111  callbackContext->callback(rc, &r, callbackContext->appContext);
112  }, new CoreImpl::CallbackContext<TGetUserSettingsCallback>({ callback, context }));
113 }
114 
115 inline void HighlightsImpl::OpenGroupAsync(HighlightOpenGroupParams const& params, TCallback callback, void* context)
116 {
118 
119  std::vector<NVGSDK_LocalizedPair> localePairs;
120  CoreImpl::translateLocaleTable(params.groupDescriptionLocaleTable, localePairs);
121  cParams.groupId = params.groupId.c_str();
122  cParams.groupDescriptionTable = &localePairs[0];
123  cParams.groupDescriptionTableSize = localePairs.size();
124 
125  NVGSDK_Highlights_OpenGroupAsync(m_handle, &cParams, CoreImpl::callbackWrapper, new CoreImpl::CallbackContext<TCallback>({ callback, context }));
126 }
127 
128 inline void HighlightsImpl::CloseGroupAsync(HighlightCloseGroupParams const& params, TCallback callback, void* context)
129 {
131  cParams.groupId = params.groupId.c_str();
132  cParams.destroyHighlights = params.destroyHighlights;
133 
134  NVGSDK_Highlights_CloseGroupAsync(m_handle, &cParams, CoreImpl::callbackWrapper, new CoreImpl::CallbackContext<TCallback>({ callback, context }));
135 }
136 
137 inline void HighlightsImpl::SetScreenshotHighlightAsync(ScreenshotHighlightParams const& params, TCallback callback, void* context)
138 {
140  cParams.groupId = params.groupId.c_str();
141  cParams.highlightId = params.highlightId.c_str();
142  NVGSDK_Highlights_SetScreenshotHighlightAsync(m_handle, &cParams, CoreImpl::callbackWrapper, new CoreImpl::CallbackContext<TCallback>({ callback, context }));
143 }
144 
145 inline void HighlightsImpl::SetVideoHighlightAsync(VideoHighlightParams const& params, TCallback callback, void* context)
146 {
148  cParams.groupId = params.groupId.c_str();
149  cParams.highlightId = params.highlightId.c_str();
150  cParams.startDelta = params.startDelta;
151  cParams.endDelta = params.endDelta;
152  NVGSDK_Highlights_SetVideoHighlightAsync(m_handle, &cParams, CoreImpl::callbackWrapper, new CoreImpl::CallbackContext<TCallback>({ callback, context }));
153 }
154 
155 inline void HighlightsImpl::OpenSummaryAsync(SummaryParams const& params, TCallback callback, void* context)
156 {
157  std::vector<NVGSDK_GroupView> cGroupViews;
158  for (auto it = params.groupViews.begin(); it != params.groupViews.end(); ++it)
159  {
160  cGroupViews.push_back({
161  it->groupId.c_str(),
162  it->tagsFilter,
163  it->significanceFilter
164  });
165  }
166 
167  NVGSDK_SummaryParams cParams;
168  cParams.groupSummaryTable = &cGroupViews[0];
169  cParams.groupSummaryTableSize = cGroupViews.size();
170  NVGSDK_Highlights_OpenSummaryAsync(m_handle, &cParams, CoreImpl::callbackWrapper, new CoreImpl::CallbackContext<TCallback>({ callback, context }));
171 }
172 
173 inline void HighlightsImpl::GetNumberOfHighlightsAsync(GroupView const& params, TGetNumberOfHighlightsCallback callback, void* context)
174 {
175  NVGSDK_GroupView cParams;
176  cParams.groupId = params.groupId.c_str();
177  cParams.tagsFilter = params.tagsFilter;
178  cParams.significanceFilter = params.significanceFilter;
179  NVGSDK_Highlights_GetNumberOfHighlightsAsync(m_handle, &cParams, [](NVGSDK_RetCode rc, NVGSDK_Highlights_NumberOfHighlights const* data, void* context) {
180  std::unique_ptr<CoreImpl::CallbackContext<TGetNumberOfHighlightsCallback>> callbackContext(reinterpret_cast<CoreImpl::CallbackContext<TGetNumberOfHighlightsCallback>*>(context));
181  if (!callbackContext->callback) return;
182 
183  if (NVGSDK_FAILED(rc))
184  {
185  return callbackContext->callback(rc, nullptr, callbackContext->appContext);
186  }
187 
189  num.numHighlights = data->numberOfHighlights;
190  callbackContext->callback(rc, &num, callbackContext->appContext);
191  }, new CoreImpl::CallbackContext<TGetNumberOfHighlightsCallback>({ callback, context }));
192 }
193 
194 }
195 
196 #endif //GFESDK_IHIGHLIGHTS_CPP_IMPL_H
char const * groupId
Required ID of the group this highlight is attached to.
int32_t endDelta
Milliseconds between the time of request, and end of desired video clip.
C++ binding for NVGSDK_SummaryParams.
NVGSDK_HighlightSignificance significanceFilter
If not zero, represents a bitfield of significance values to include.
virtual void GetNumberOfHighlightsAsync(GroupView const &params, TGetNumberOfHighlightsCallback cb=nullptr, void *cbContext=nullptr)
C++ binding for NVGSDK_ScreenshotHighlightParams.
bool enabled
Boolean for whether the user wants to record this type of highlight.
C++ binding for NVGSDK_HighlightCloseGroupParams.
C++ binding for NVGSDK_HighlightOpenGroupParams.
virtual void SetVideoHighlightAsync(VideoHighlightParams const &params, TCallback cb=nullptr, void *cbContext=nullptr)
C++ binding for NVGSDK_Highlights_GetUserSettingsResponse.
char const * highlightId
Refers to unique highlight id in highlight table.
virtual void CloseGroupAsync(HighlightCloseGroupParams const &params, TCallback cb=nullptr, void *cbContext=nullptr)
char const * groupId
Required ID of the group this highlight is attached to.
char const * defaultLocale
Default locality, used for hinting GFE which translation to use. Defaults to en-us.
virtual void OpenGroupAsync(HighlightOpenGroupParams const &params, TCallback cb=nullptr, void *cbContext=nullptr)
C++ binding for NVGSDK_HighlightConfigParams.
NVGSDK_EXPORT void NVGSDKApi NVGSDK_Highlights_OpenGroupAsync(NVGSDK_HANDLE *handle, NVGSDK_HighlightOpenGroupParams const *params, NVGSDK_EmptyCallback callback, void *context)
C++ binding for NVGSDK_VideoHighlightParams.
virtual void OpenSummaryAsync(SummaryParams const &params, TCallback cb=nullptr, void *cbContext=nullptr)
NVGSDK_LocalizedPair * groupDescriptionTable
char const * highlightId
Refers to unique highlight id in highlight table.
NVGSDK_GroupView * groupSummaryTable
Pass in all the groups to display on screen.
NVGSDK_EXPORT void NVGSDKApi NVGSDK_Highlights_GetUserSettingsAsync(NVGSDK_HANDLE *handle, NVGSDK_Highlights_GetUserSettingsCallback cb, void *cbContext)
char const * id
Unique id for game event.
NVGSDK_EXPORT void NVGSDKApi NVGSDK_Highlights_SetScreenshotHighlightAsync(NVGSDK_HANDLE *handle, NVGSDK_ScreenshotHighlightParams const *params, NVGSDK_EmptyCallback callback, void *context)
size_t groupSummaryTableSize
Number of groups contained in the table pointer.
NVGSDK_EXPORT void NVGSDKApi NVGSDK_Highlights_ConfigureAsync(NVGSDK_HANDLE *handle, NVGSDK_HighlightConfigParams const *config, NVGSDK_EmptyCallback callback, void *context)
NVGSDK_EXPORT void NVGSDKApi NVGSDK_Highlights_GetNumberOfHighlightsAsync(NVGSDK_HANDLE *handle, NVGSDK_GroupView const *groupParams, NVGSDK_Highlights_GetNumberOfHighlightsCallback cb, void *context)
virtual void SetScreenshotHighlightAsync(ScreenshotHighlightParams const &params, TCallback cb=nullptr, void *cbContext=nullptr)
C++ binding for NVGSDK_GroupView.
NVGSDK_EXPORT void NVGSDKApi NVGSDK_Highlights_CloseGroupAsync(NVGSDK_HANDLE *handle, NVGSDK_HighlightCloseGroupParams const *params, NVGSDK_EmptyCallback callback, void *context)
char const * groupId
Unique ID of the group to open.
NVGSDK_EXPORT void NVGSDKApi NVGSDK_Highlights_SetVideoHighlightAsync(NVGSDK_HANDLE *handle, NVGSDK_VideoHighlightParams const *, NVGSDK_EmptyCallback callback, void *context)
virtual void ConfigureAsync(HighlightConfigParams const &params, TCallback cb=nullptr, void *cbContext=nullptr)
C++ binding for NVGSDK_GetNumberOfHighlightsResponse.
int32_t startDelta
Milliseconds between the time of request, and the start of desired video clip.
size_t groupDescriptionTableSize
Number of entries in the groupDescriptionTable */.
NVGSDK_HighlightType tagsFilter
If not zero, represents a bitfield of tags to include.
virtual void GetUserSettingsAsync(TGetUserSettingsCallback cb=nullptr, void *cbContext=nullptr) const
NVGSDK_EXPORT void NVGSDKApi NVGSDK_Highlights_OpenSummaryAsync(NVGSDK_HANDLE *handle, NVGSDK_SummaryParams const *params, NVGSDK_EmptyCallback callback, void *context)
char const * groupId
Unique group ID that was used to Open a group previously.