Agora Java API Reference for Android
Public Member Functions | List of all members
agora::streaming::IStreamingKit Class Referenceabstract

#include <IAgoraStreamingKit.h>

Public Member Functions

virtual int initialize (const StreamingContext &context)=0
 
virtual void release (bool sync=false)=0
 
virtual int startStreaming (const char *publishUrl)=0
 
virtual int stopStreaming ()=0
 
virtual int enableAudioRecording (bool enabled)=0
 
virtual int enableVideoCapturing (bool enabled)=0
 
virtual int muteAudioStream (bool muted)=0
 
virtual int muteVideoStream (bool muted)=0
 
virtual int setAudioStreamConfiguration (const AudioStreamConfiguration &config)=0
 
virtual int setVideoStreamConfiguration (const VideoStreamConfiguration &config)=0
 
virtual int switchResolution (int width, int height)=0
 
virtual int snapshot (agora::streaming::ISnapshotCallback *callback)=0
 
virtual int adjustRecordingSignalVolume (int volume)=0
 
virtual int setExternalAudioSource (bool enable)=0
 
virtual int setExternalVideoSource (bool enable)=0
 
virtual int pushExternalVideoFrame (const media::IVideoFrameObserver::VideoFrame &Frame)=0
 
virtual int pushExternalAudioFrame (const media::IAudioFrameObserver::AudioFrame &frame)=0
 
virtual IAudioDeviceManagergetAudioDeviceManager ()=0
 
virtual IVideoDeviceManagergetVideoDeviceManager ()=0
 
virtual IVideoPreviewRenderergetVideoPreviewRenderer ()=0
 
virtual int registerAudioFrameObserver (media::base::IAudioFrameObserver *observer)=0
 
virtual void unregisterAudioFrameObserver (media::base::IAudioFrameObserver *observer)=0
 
virtual int registerVideoFrameObserver (media::base::IVideoFrameObserver *observer)=0
 
virtual void unregisterVideoFrameObserver (media::base::IVideoFrameObserver *observer)=0
 
virtual int setLogFile (const char *filePath)=0
 
virtual int setLogFilter (unsigned int filter)=0
 
virtual int setLogFileSize (unsigned int fileSizeInKBytes)=0
 

Detailed Description

The IStreamingKit class.

This class provides the main methods that can be invoked by your app.

Creating an IStreamingKit object and then calling the methods of this object enables you to use Agora SDK's live streaming functionality.

Member Function Documentation

◆ initialize()

virtual int agora::streaming::IStreamingKit::initialize ( const StreamingContext context)
pure virtual

Initializes the Agora streaming kit.

In this method, you need to enter the issued Agora App ID to start initialization. After creating an IStreamingKit object, call this method to initialize the kit before calling any other methods.

Parameters
contextThe StreamingContext object.
audioTrackThe local audio track. Must not be NULL if audio streaming is enabled.
videoTrackThe local video track. Must not be NULL if video streaming is enabled.
Returns
  • 0: Success.
  • < 0: Failure.

◆ release()

virtual void agora::streaming::IStreamingKit::release ( bool  sync = false)
pure virtual

Releases the IStreamingKit object.

Parameters
syncDetermines whether this method is a synchronous call.
  • true: This method is a synchronous call, which means that the result of this method call returns after the IStreamingKit object resources are released. Do not call this method in any callback generated by the streaming kit, or it may result in a deadlock.
  • false: This method is an asynchronous call. The result returns immediately even when the IStreamingKit object resources are not released.
Returns
  • 0: Success.
  • < 0: Failure.

◆ startStreaming()

virtual int agora::streaming::IStreamingKit::startStreaming ( const char *  publishUrl)
pure virtual

Start media streaming

Parameters
publishUrlThe CDN streaming URL in the RTMP format. The maximum length of this parameter is 1024 bytes. The URL address must not contain special characters, such as Chinese language characters.
Returns
  • 0: Success.
  • < 0: Failure.

◆ stopStreaming()

virtual int agora::streaming::IStreamingKit::stopStreaming ( )
pure virtual

stop media streaming

Returns
  • 0: Success.
  • < 0: Failure.

◆ enableAudioRecording()

virtual int agora::streaming::IStreamingKit::enableAudioRecording ( bool  enabled)
pure virtual

Enables or disables audio recording.

Parameters
enabledDetermines whether to disable or re-enable audio recording:
  • true: (Default) Re-enable audio recording.
  • false: Disable audio recording.
Returns
  • 0: Success.
  • < 0: Failure.

◆ enableVideoCapturing()

virtual int agora::streaming::IStreamingKit::enableVideoCapturing ( bool  enabled)
pure virtual

Enables or disables video capturing.

Parameters
enabledDetermines whether to disable or re-enable video capturing:
  • true: (Default) Re-enable video capturing.
  • false: Disable video capturing.
Returns
  • 0: Success.
  • < 0: Failure.

◆ muteAudioStream()

virtual int agora::streaming::IStreamingKit::muteAudioStream ( bool  muted)
pure virtual

Stops or resumes publishing the audio stream.

Parameters
mutedDetermines whether to publish or stop publishing the audio stream:
  • true: Stop publishing the audio stream.
  • false: (Default) Publish the audio stream.
Returns
  • 0: Success.
  • < 0: Failure.

◆ muteVideoStream()

virtual int agora::streaming::IStreamingKit::muteVideoStream ( bool  muted)
pure virtual

Stops or resumes publishing the video stream.

Parameters
mutedDetermines whether to publish or stop publishing the video stream:
  • true: Stop publishing the video stream.
  • false: (Default) Publish the video stream.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setAudioStreamConfiguration()

virtual int agora::streaming::IStreamingKit::setAudioStreamConfiguration ( const AudioStreamConfiguration config)
pure virtual

Sets the audio stream configuration.

Each configuration corresponds to a set of audio parameters, including the audio sample rate, bytes per sample, number of channels, and bitrate.

Parameters
configThe audio stream configuration: AudioStreamConfiguration.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setVideoStreamConfiguration()

virtual int agora::streaming::IStreamingKit::setVideoStreamConfiguration ( const VideoStreamConfiguration config)
pure virtual

Sets the video stream configuration.

Each configuration corresponds to a set of video parameters, including the resolution, frame rate, and bitrate.

Parameters
configThe video stream configuration: VideoStreamConfiguration.
Returns
  • 0: Success.
  • < 0: Failure.

◆ switchResolution()

virtual int agora::streaming::IStreamingKit::switchResolution ( int  width,
int  height 
)
pure virtual

switch the video resolution on preview.

Minimum resolution support 64*64 Maximum resolution support 1920*1080

Parameters
widthThe width of video.
heightThe height of video.
Returns
  • 0: Success.
  • < 0: Failure.

◆ snapshot()

virtual int agora::streaming::IStreamingKit::snapshot ( agora::streaming::ISnapshotCallback callback)
pure virtual

snapshot a picture on pushing.

Parameters
callbackcallback a bitmap
Returns
  • 0: Success.
  • < 0: Failure.

◆ adjustRecordingSignalVolume()

virtual int agora::streaming::IStreamingKit::adjustRecordingSignalVolume ( int  volume)
pure virtual

Adjusts the recording volume.

Parameters
volumeThe recording volume, which ranges from 0 to 400:
  • 0: Mute the recoridng volume.
  • 100: The Original volume.
  • 400: (Maximum) Four times the original volume with signal clipping protection.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setExternalAudioSource()

virtual int agora::streaming::IStreamingKit::setExternalAudioSource ( bool  enable)
pure virtual

Enables the external audio source.

Call this method before push streaming.

Parameters
enableDetermines whether to enable the external audio source.
Returns
0: Success. < 0: Failure.

◆ setExternalVideoSource()

virtual int agora::streaming::IStreamingKit::setExternalVideoSource ( bool  enable)
pure virtual

Enables the external video source.

Call this method before push streaming.

Parameters
enableDetermines whether to enable the external video source.
Returns
0: Success. < 0: Failure.

◆ pushExternalVideoFrame()

virtual int agora::streaming::IStreamingKit::pushExternalVideoFrame ( const media::IVideoFrameObserver::VideoFrame &  Frame)
pure virtual

Pushes the external video frame to the app.

Parameters
frameThe video buffer data.
Returns
  • 0: Success.
  • < 0: Failure.

◆ pushExternalAudioFrame()

virtual int agora::streaming::IStreamingKit::pushExternalAudioFrame ( const media::IAudioFrameObserver::AudioFrame &  frame)
pure virtual

Pushes the external audio data to the app.

Parameters
frameThe audio buffer data.
Returns
  • 0: Success.
  • < 0: Failure.

◆ getAudioDeviceManager()

virtual IAudioDeviceManager* agora::streaming::IStreamingKit::getAudioDeviceManager ( )
pure virtual

Get the audio device manager

Returns
  • Returns an IAudioDeviceManager object that provides the method to manage the audio devices when the call succeeds.
  • Returns NULL when the call fails (for example, custom audio input is used).

◆ getVideoDeviceManager()

virtual IVideoDeviceManager* agora::streaming::IStreamingKit::getVideoDeviceManager ( )
pure virtual

Get the video device manager

Returns
  • Returns an IVideoDeviceManager object that provides the method to manage the video devices when the call succeeds.
  • Returns NULL when the call fails (for example, custom video input is used).

◆ getVideoPreviewRenderer()

virtual IVideoPreviewRenderer* agora::streaming::IStreamingKit::getVideoPreviewRenderer ( )
pure virtual

Get the video preview renderer

Returns
  • Returns an IVideoPreviewRenderer object that provides the method to manger the video preview rendering when the call succeeds.
  • Returns NULL when the call fails.

◆ registerAudioFrameObserver()

virtual int agora::streaming::IStreamingKit::registerAudioFrameObserver ( media::base::IAudioFrameObserver *  observer)
pure virtual

Registers an audio frame observer object.

Parameters
observerA pointer to the audio frame observer object: IAudioFrameObserver.
Returns
  • 0: Success.
  • < 0: Failure.

◆ unregisterAudioFrameObserver()

virtual void agora::streaming::IStreamingKit::unregisterAudioFrameObserver ( media::base::IAudioFrameObserver *  observer)
pure virtual

Unregisters an audio frame observer object.

Parameters
observerA pointer to the audio frame observer object: IAudioFrameObserver.

◆ registerVideoFrameObserver()

virtual int agora::streaming::IStreamingKit::registerVideoFrameObserver ( media::base::IVideoFrameObserver *  observer)
pure virtual

Registers a video frame observer object.

Parameters
observerA pointer to the video frame observer: IVideoFrameObserver.
Returns
  • 0: Success.
  • < 0: Failure.

◆ unregisterVideoFrameObserver()

virtual void agora::streaming::IStreamingKit::unregisterVideoFrameObserver ( media::base::IVideoFrameObserver *  observer)
pure virtual

Unregisters a video frame observer object.

Parameters
observerA pointer to the video frame observer: IVideoFrameObserver.

◆ setLogFile()

virtual int agora::streaming::IStreamingKit::setLogFile ( const char *  filePath)
pure virtual

Specifies an output log file for the streaming kit.

The log file records all log data for the kit's operation. Ensure that the directory for the log file exists and is writable.

Note
Ensure that you call this method immediately after initialize, or the output log may not be complete.
Parameters
filePathFile path of the log file. The string of the log file is in UTF-8.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setLogFilter()

virtual int agora::streaming::IStreamingKit::setLogFilter ( unsigned int  filter)
pure virtual

Sets the output log level of the kit.

You can use one or a combination of the filters. The log level follows the sequence of OFF, CRITICAL, ERROR, WARNING, INFO, and DEBUG. Choose a level and you will see logs preceding that level. For example, if you set the log level to WARNING, you see the logs within levels CRITICAL, ERROR, and WARNING.

Parameters
filterSets the log filter level:
  • LOG_FILTER_DEBUG: Output all API logs. Set your log filter as DEBUG if you want to get the most complete log file.
  • LOG_FILTER_INFO: Output logs of the CRITICAL, ERROR, WARNING, and INFO level. We recommend setting your log filter as this level.
  • LOG_FILTER_WARNING: Output logs of the CRITICAL, ERROR, and WARNING level.
  • LOG_FILTER_ERROR: Output logs of the CRITICAL and ERROR level.
  • LOG_FILTER_CRITICAL: Output logs of the CRITICAL level.
  • LOG_FILTER_OFF: Do not output any log.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setLogFileSize()

virtual int agora::streaming::IStreamingKit::setLogFileSize ( unsigned int  fileSizeInKBytes)
pure virtual

Sets the log file size (KB).

The SDK has two log files, each with a default size of 512 KB. If you set fileSizeInBytes as 1024 KB, the SDK outputs log files with a total maximum size of 2 MB. If the total size of the log files exceed the set value, the new output log files overwrite the old output log files.

Parameters
fileSizeInKBytesThe SDK log file size (KB).
Returns
  • 0: Success.
  • <0: Failure.