|
Twitch SDK (Internal)
|
#include <adsapi.h>
Classes | |
| class | CoreApiClient |
Public Types | |
| using | FetchAdsCallback = std::function< void(TTV_ErrorCode ec, std::vector< Ad > &&result)> |
| using | ReportAdEventsCallback = std::function< void(TTV_ErrorCode ec)> |
| enum | State { State::Uninitialized, State::Initializing, State::Initialized, State::ShuttingDown } |
| using | InitializeCallback = std::function< void(TTV_ErrorCode ec)> |
| using | ShutdownCallback = std::function< void(TTV_ErrorCode ec)> |
Public Member Functions | |
| AdsAPI () | |
| virtual | ~AdsAPI () |
| virtual std::string | GetModuleName () const override |
| virtual TTV_ErrorCode | Initialize (const InitializeCallback &callback) override |
| virtual TTV_ErrorCode | Shutdown (const ShutdownCallback &callback) override |
| virtual TTV_ErrorCode | Update () override |
| TTV_ErrorCode | SetCoreApi (const std::shared_ptr< CoreAPI > &coreApi) |
| TTV_ErrorCode | FetchAds (const AdConfiguration &config, const AdFetchRequestInfo &info, const FetchAdsCallback &callback) |
| TTV_ErrorCode | ReportAdEvent (const std::string &url, const std::map< std::string, std::string > ¯oSubstitutions, const ReportAdEventsCallback &callback) |
| TTV_ErrorCode | ReportAdEvents (const std::vector< std::string > &urls, const std::map< std::string, std::string > ¯oSubstitutions) |
| virtual State | GetState () const override |
Protected Member Functions | |
| virtual bool | CheckShutdown () override |
| virtual void | CompleteShutdown () override |
| void | NotifyStateChange () |
| void | RegisterInitializeCallback (const InitializeCallback &callback) |
| void | RegisterShutdownCallback (const ShutdownCallback &callback) |
| template<typename T > | |
| void | Invoke (std::function< void(std::shared_ptr< T >)> callback) |
| std::shared_ptr< ComponentContainer > | GetComponentContainer () |
Protected Attributes | |
| EventSource< IModuleListener > | mListeners |
| State | mState |
| State | mLastReportedState |
Private Attributes | |
| std::shared_ptr< CoreAPI > | mCoreApi |
| std::shared_ptr< TaskRunner > | mTaskRunner |
| std::shared_ptr< CoreApiClient > | mCoreApiClient |
Provides client-side VAST functionality.
The following properties must be set before calling Initialize().
There are 2 main methods.
| using ttv::ads::AdsAPI::FetchAdsCallback = std::function<void(TTV_ErrorCode ec, std::vector<Ad>&& result)> |
|
inherited |
| using ttv::ads::AdsAPI::ReportAdEventsCallback = std::function<void(TTV_ErrorCode ec)> |
|
inherited |
|
stronginherited |
| ttv::ads::AdsAPI::AdsAPI | ( | ) |
|
virtual |
|
overrideprotectedvirtual |
Reimplemented from ttv::ModuleBase.
|
overrideprotectedvirtual |
Reimplemented from ttv::ModuleBase.
| TTV_ErrorCode ttv::ads::AdsAPI::FetchAds | ( | const AdConfiguration & | config, |
| const AdFetchRequestInfo & | info, | ||
| const FetchAdsCallback & | callback | ||
| ) |
Fetches a pod of ads using the given config and info. See AdConfiguration and AdFetchRequestInfo for options. MediaFiles within LinearCreatives will be returned sorted by decreasing width.
|
inlineprotectedinherited |
Returns the common ComponentContainer which hosts all components which live at the module level.
|
overridevirtual |
Returns the name of the module.
Implements ttv::IModule.
|
overridevirtualinherited |
Returns the current state of the module.
Implements ttv::IModule.
|
overridevirtual |
Initializes the module asynchronously. The module state will be reported in IModuleListener::ModuleStateChanged(). No other calls should be made into the module until the module state is either State::Initialized or State::Uninitialized. You should only expect changes to the module state if this method succeeds.
Reimplemented from ttv::ModuleBase.
|
inlineprotectedinherited |
Invokes the callback for the module listeners.
|
protectedinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
| TTV_ErrorCode ttv::ads::AdsAPI::ReportAdEvent | ( | const std::string & | url, |
| const std::map< std::string, std::string > & | macroSubstitutions, | ||
| const ReportAdEventsCallback & | callback | ||
| ) |
Report tracking info to the passed-in URL. This can be used for the following cases:
The URLs provided by the VAST server often include square-bracket-enclosed macro strings for which the client can provide replacement values. The client can provide these values with the macroSubstitutions parameter, with the keys being lower-cased strings of the macro name. The values are automatically percent encoded by the request before being injected into the URL. Any values not provided are replaced with an empty string, with the exception of the "cachebusting" macro which is automatically replaced with an 8-digit random number as per the VAST specification.
| TTV_ErrorCode ttv::ads::AdsAPI::ReportAdEvents | ( | const std::vector< std::string > & | urls, |
| const std::map< std::string, std::string > & | macroSubstitutions | ||
| ) |
Similar to ReportAdEvent but handles a batch of urls. There is no success or failure callback. If you require confirmation of success use ReportAdEvent in a loop to know which urls are failing.
| TTV_ErrorCode ttv::ads::AdsAPI::SetCoreApi | ( | const std::shared_ptr< CoreAPI > & | coreApi | ) |
|
overridevirtual |
Initiates an asynchronous shutdown of the module. The module state will be reported in IModuleListener::ModuleStateChanged(). No other calls should be made into the module until the module state is either State::Initialized or State::Uninitialized. All modules that depend on this module need to be shutdown first. You should only expect changes to the module state if this method succeeds.
Reimplemented from ttv::ModuleBase.
|
overridevirtual |
Updates the internal state of the module and fires any pending callbacks.
Reimplemented from ttv::ModuleBase.
|
private |
|
private |
|
protectedinherited |
|
protectedinherited |
The registered listeners. These listeners extend IModuleListener and will be of the type required for the module.
|
protectedinherited |
|
private |
1.8.13