|
Twitch SDK (Internal)
|
#include <broadcastapi.h>
Classes | |
| class | CoreApiClient |
Public Types | |
| using | StartBroadcastCallback = std::function< void(TTV_ErrorCode ec)> |
| using | StopBroadcastCallback = std::function< void(TTV_ErrorCode ec)> |
| using | FetchIngestListCallback = std::function< void(TTV_ErrorCode ec, std::vector< IngestServer > &&result)> |
| using | RunCommercialCallback = std::function< void(TTV_ErrorCode ec)> |
| using | SetStreamInfoCallback = 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)> |
Static Public Member Functions | |
| static void | GetRequiredAuthScopes (std::vector< std::string > &scopes) |
Protected Member Functions | |
| 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 Member Functions | |
| void | CoreUserLoggedIn (std::shared_ptr< User > user) |
| void | CoreUserLoggedOut (std::shared_ptr< User > user) |
| virtual bool | CheckShutdown () override |
| virtual void | CompleteShutdown () override |
| std::shared_ptr< Streamer > | CreateStreamer (const std::shared_ptr< User > &user) |
| std::shared_ptr< TwitchAPI > | CreateTwitchAPI (const std::shared_ptr< User > &user) |
| TTV_ErrorCode | GetStreamer (std::shared_ptr< Streamer > &result) |
| TTV_ErrorCode | EnsureBroadcastingAndGetStreamer (std::shared_ptr< Streamer > &result) |
| TTV_ErrorCode | EnsureNotBroadcastingAndGetStreamer (std::shared_ptr< Streamer > &result) |
| TTV_ErrorCode | BindToUser (const std::shared_ptr< User > &user) |
| void | SetBroadcastState (TTV_ErrorCode ec, BroadcastState state) |
Private Attributes | |
| std::shared_ptr< BroadcastApiInternalData > | mInternalData |
| std::shared_ptr< CoreApiClient > | mCoreApiClient |
| The client instance registered with CoreAPI. More... | |
This module provides the ability to broadcast to Twitch by accepting video and audio data from a game/app, encoding it and sending it to the Twitch backend in realtime.
The following properties must be set before calling Initialize().
In order to broadcast several services must be configured using the following methods.
The video parameters must also be set via one of the 2 following methods.
Currently, only one user may be broadcasting at a time. In order to specify which user will broadcast SetActiveUser() must be used. The active user must be set and the user logged in before configuring any of the encoders, capturers and other settings. If the active user is changed or logged out then the configuration is lost.
If you have a custom application which has a need to access the raw encoded data then see the SetCustomMuxer() method.
| using ttv::broadcast::BroadcastAPI::FetchIngestListCallback = std::function<void(TTV_ErrorCode ec, std::vector<IngestServer>&& result)> |
|
inherited |
| using ttv::broadcast::BroadcastAPI::RunCommercialCallback = std::function<void(TTV_ErrorCode ec)> |
| using ttv::broadcast::BroadcastAPI::SetStreamInfoCallback = std::function<void(TTV_ErrorCode ec)> |
|
inherited |
| using ttv::broadcast::BroadcastAPI::StartBroadcastCallback = std::function<void(TTV_ErrorCode ec)> |
| using ttv::broadcast::BroadcastAPI::StopBroadcastCallback = std::function<void(TTV_ErrorCode ec)> |
|
stronginherited |
| ttv::broadcast::BroadcastAPI::BroadcastAPI | ( | ) |
|
virtual |
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::AddBandwidthStatListener | ( | const std::shared_ptr< IBandwidthStatListener > & | listener | ) |
Adds a listener that will be periodically called back with statistics about network usage. This should not be invoked while broadcasting.
|
private |
|
overrideprivatevirtual |
Reimplemented from ttv::ModuleBase.
|
overrideprivatevirtual |
Reimplemented from ttv::ModuleBase.
|
private |
|
private |
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::CreateIngestTester | ( | UserId | userId, |
| const std::shared_ptr< IIngestTesterListener > & | listener, | ||
| const uint8_t * | testDataBuffer, | ||
| uint32_t | testDataLength, | ||
| std::shared_ptr< IIngestTester > & | result | ||
| ) |
Returns an implementation of IIngestTester for the given owning user. When done with the implementation it must be released via DisposeIngestTester().
|
private |
|
private |
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::DisposeIngestTester | ( | const std::shared_ptr< IIngestTester > & | ingestTester | ) |
Releases the given IIngestTester implementation that was returned by CreateIngestTester().
|
private |
|
private |
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::FetchIngestServerList | ( | FetchIngestListCallback && | callback | ) |
Fetches the list of available ingest servers that can be used for broadcasting.
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::GetBroadcastState | ( | BroadcastState & | result | ) | const |
Retrieves the current state of broadcasting.
|
inlineprotectedinherited |
Returns the common ComponentContainer which hosts all components which live at the module level.
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::GetCurrentBroadcastTime | ( | uint64_t & | broadcastTime | ) |
Retrieves the current time in the live broadcast.
|
overridevirtual |
Returns the name of the module.
Implements ttv::IModule.
|
static |
Retrieves the OAuth token scopes required to support all features in this module.
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::GetSelectedIngestServer | ( | IngestServer & | result | ) |
Retrieves the currently selected ingest server. It's possible that none is selected and will contain empty values.
|
overridevirtualinherited |
Returns the current state of the module.
Implements ttv::IModule.
|
private |
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::GetVideoParams | ( | VideoParams & | videoParams | ) |
Retrieves the currently set VideoParams.
|
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::broadcast::BroadcastAPI::RemoveAudioCapturer | ( | AudioLayerId | layer | ) |
Removes a previously added audio capturer for the given layer.
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::RemoveBandwidthStatListener | ( | const std::shared_ptr< IBandwidthStatListener > & | listener | ) |
Removes a previously added bandwidth stat listener. This should not be invoked while broadcasting.
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::RunCommercial | ( | UserId | userId, |
| ChannelId | channelId, | ||
| uint32_t | timebreakSeconds, | ||
| RunCommercialCallback && | callback | ||
| ) |
Triggers a commercial of the specified duration in seconds. This may be triggered independently from whether or not a broadcast is in progress. Note that only partnered users may run commercials.
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::SetActiveUser | ( | UserId | userId | ) |
Sets the userid of the user who will be broadcasting. This must be set before attempting to broadcast and cannot be changed while broadcasting. See the class description for more details.
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::SetAudioCapturer | ( | AudioLayerId | layer, |
| const std::shared_ptr< IAudioCapture > & | capturer | ||
| ) |
Sets the source of audio samples for the given layer. The layer ids are up to the client but generally start at 0 and increment for each layer the application adds. For instance, a capturer for system audio could be added for layer 0 and a microphone capturer added for layer 1.
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::SetAudioEncoder | ( | const std::shared_ptr< IAudioEncoder > & | encoder | ) |
Sets the desired audio encoder to use.
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::SetAudioLayerEnabled | ( | AudioLayerId | layer, |
| bool | enabled | ||
| ) |
This will enable or disable the associated capturer for the entire broadcast. This cannot be changed while broadcasting. The IAudioCapture for the layer must already be set via SetAudioCapturer().
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::SetAudioLayerMuted | ( | AudioLayerId | layer, |
| bool | muted | ||
| ) |
This mutes the audio for the given audio layer and can be toggled freely during a stream. The IAudioCapture for the layer must already be set via SetAudioCapturer().
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::SetAudioLayerVolume | ( | AudioLayerId | layer, |
| float | volume | ||
| ) |
Sets the volume of given audio layer and can be toggled freely during a stream. The IAudioCapture for the layer must already be set via SetAudioCapturer().
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::SetBroadcasterSoftware | ( | const std::string & | str | ) |
Sets the broadcaster_software value associated with the stream so the software used can be identified.
|
private |
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::SetConnectionType | ( | ConnectionType | connectionType | ) |
Sets the type of connection that will be used to broadcast. This value is used when sending tracking events.
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::SetCoreApi | ( | const std::shared_ptr< CoreAPI > & | coreApi | ) |
Sets the CoreAPI instance to use for low level services. This must be set before Initialize() is called.
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::SetCustomMuxer | ( | const std::shared_ptr< IMuxer > & | muxer | ) |
Sets an optional receiver of post-encoded video and audio data. This can only be called before starting a broadcast.
| muxer | A custom IMuxer implementation which allow an application to obtain the raw encoded data. |
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::SetForceArchiveBroadcast | ( | bool | forceArchive | ) |
Sets the flag which forces the recording of the broadcast on the server (recorder=1 in the RTMP URL)
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::SetListener | ( | const std::shared_ptr< IBroadcastAPIListener > & | listener | ) |
Sets the client listener implementation. This must be set before Initialize() is called.
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::SetOutputPath | ( | const std::wstring & | outputPath | ) |
Sets the output FLV file path for saving a broadcast locally for debugging and verification.
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::SetSelectedIngestServer | ( | const IngestServer & | server | ) |
Sets the selected ingest server to use when initiating broadcasts.
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::SetSessionId | ( | const std::string & | sessionId | ) |
Sets a unique ID for the broadcasting session, which can span multiple starts/stops. This value is used when sending tracking events.
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::SetStreamInfo | ( | UserId | userId, |
| ChannelId | channelId, | ||
| const std::string & | game, | ||
| const std::string & | title, | ||
| SetStreamInfoCallback && | callback | ||
| ) |
Sets the current game and stream title for a channel. These values may be set independently from whether or not a broadcast is in progress.
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::SetVideoCapturer | ( | const std::shared_ptr< IVideoCapture > & | capturer | ) |
Sets the source of video frames.
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::SetVideoEncoder | ( | const std::shared_ptr< IVideoEncoder > & | encoder | ) |
Sets the desired video encoder to use.
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::SetVideoParams | ( | const VideoParams & | videoParams | ) |
Sets the VideoParams to use for the broadcast. This cannot be set while a stream is in progress.
|
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.
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::StartBroadcast | ( | StartBroadcastCallback && | callback | ) |
Initiates broadcasting for the active user.
| TTV_ErrorCode ttv::broadcast::BroadcastAPI::StopBroadcast | ( | const std::string & | reason, |
| StopBroadcastCallback && | callback | ||
| ) |
Gracefully stops broadcasting.
| [in] | reason | A string describing why the stream is being stopped, used for tracking. Pass in "user_ended" if this was an explicit action from the user. |
|
overridevirtual |
Updates the internal state of the module and fires any pending callbacks.
Reimplemented from ttv::ModuleBase.
|
private |
The client instance registered with CoreAPI.
|
private |
|
protectedinherited |
|
protectedinherited |
The registered listeners. These listeners extend IModuleListener and will be of the type required for the module.
|
protectedinherited |
1.8.13