CDN Streaming

setDirectCdnStreamingAudioConfiguration

Sets the audio configuration for direct CDN streaming by the host.

public abstract int setDirectCdnStreamingAudioConfiguration(int profile)
Deprecated
Deprecated since v4.6.0.

When you set publishMicrophoneTrack or publishCustomAudioTrack to true in DirectCdnStreamingMediaOptions, you can call this method to set the audio configuration.

Parameters

profile
Audio configuration including sample rate, bitrate, codec mode, and number of channels:
  • DEFAULT (0): Default configuration.
    • Live interactive: 48 kHz sample rate, music codec, mono, max 64 Kbps.
    • Communication: 32 kHz sample rate, speech codec, mono, max 18 Kbps.
  • SPEECH_STANDARD (1): 32 kHz sample rate, speech codec, mono, max 18 Kbps.
  • MUSIC_STANDARD (2): 48 kHz sample rate, music codec, mono, max 64 Kbps.
  • MUSIC_STANDARD_STEREO (3): 48 kHz sample rate, music codec, stereo, max 80 Kbps.
  • MUSIC_HIGH_QUALITY (4): 48 kHz sample rate, music codec, mono, max 96 Kbps.
  • MUSIC_HIGH_QUALITY_STEREO (5): 48 kHz sample rate, music codec, stereo, max 128 Kbps.

Return Values

  • 0: Success.
  • < 0: Failure.

setDirectCdnStreamingVideoConfiguration

Sets the video property configuration for direct CDN streaming by the host.

public abstract int setDirectCdnStreamingVideoConfiguration(VideoEncoderConfiguration config);
Deprecated
Deprecated since v4.6.0.

This method only affects video streams captured by the camera, screen, or custom video source. That is, when you set publishCameraTrack or publishCustomVideoTrack to true in DirectCdnStreamingMediaOptions, you can call this method to set the video property configuration. If the local camera does not support the resolution you set, the SDK automatically adjusts it to the closest resolution for capture, encoding, or streaming while maintaining the aspect ratio of your setting. You can get the actual resolution of the video stream through the onDirectCdnStreamingStats callback.

Note: During CDN live streaming, Agora only supports setting ORIENTATION_MODE to ORIENTATION_MODE_FIXED_LANDSCAPE or ORIENTATION_MODE_FIXED_PORTRAIT.

Parameters

config
Video property configuration. See VideoEncoderConfiguration.
Note: During CDN live streaming, Agora only supports setting ORIENTATION_MODE to ORIENTATION_MODE_FIXED_LANDSCAPE or ORIENTATION_MODE_FIXED_PORTRAIT.

Return Values

  • 0: Success.
  • < 0: Failure.

startDirectCdnStreaming

Starts pushing media streams directly to the CDN.

public abstract int startDirectCdnStreaming(IDirectCdnStreamingEventHandler eventHandler, String publishUrl, DirectCdnStreamingMediaOptions options);
Deprecated
Deprecated since v4.6.0.
Agora does not support setting both publishCameraTrack and publishCustomVideoTrack to true, or both publishMicrophoneTrack and publishCustomAudioTrack to true. When selecting media settings in DirectCdnStreamingMediaOptions, you can refer to the following example: If you want to push audio and video streams captured by the host from a custom source, set the media options as follows:
  • Set publishCustomAudioTrack to true and call pushExternalAudioFrame;
  • Set publishCustomVideoTrack to true and call pushExternalVideoFrameById;
  • Set publishCameraTrack to false (default);
  • Set publishMicrophoneTrack to false (default).
Since v4.2.0, the Agora SDK supports audio-only live streaming. You can set publishCustomAudioTrack or publishMicrophoneTrack to true in DirectCdnStreamingMediaOptions and call pushExternalAudioFrame to push audio streams.
Note: Agora only supports pushing one audio-video stream or one audio stream to the CDN.

Parameters

eventHandler
Event callback interface. See IDirectCdnStreamingEventHandler.
publishUrl
CDN streaming URL.
options
Media settings for the host. See DirectCdnStreamingMediaOptions.

Return Values

  • 0: Success.
  • < 0: Failure.

stopDirectCdnStreaming

Stops pushing media streams directly to the CDN.

public abstract int stopDirectCdnStreaming()
Deprecated
Deprecated since v4.6.0.

Return Values

  • 0: Success.
  • < 0: Failure.

onDirectCdnStreamingStateChanged

Callback for changes in CDN streaming state.

void onDirectCdnStreamingStateChanged(DirectCdnStreamingState state, DirectCdnStreamingReason reason, String message)

When the host pushes streams directly to the CDN and the streaming state changes, the SDK triggers this callback to report the updated streaming state, error codes, and other information. You can refer to this callback for troubleshooting.

Trigger Timing

This callback is triggered when the streaming state changes during the process of pushing streams directly to the CDN by the host.

Parameters

state
Current CDN streaming state. See DirectCdnStreamingState.
reason
Reason for the change in CDN streaming state. See DirectCdnStreamingReason.
message
Description of the streaming state change.

onDirectCdnStreamingStats

Callback for reporting CDN streaming statistics.

void onDirectCdnStreamingStats(DirectCdnStreamingStats stats)

When the host pushes media streams directly to the CDN, the SDK triggers this callback once per second.

Trigger Timing

This callback is triggered once per second when the host pushes media streams directly to the CDN.

Parameters

stats
Current CDN streaming statistics. See DirectCdnStreamingStats.