Marks whether this stream contains an audio track.
Marks whether to enable audio processing.
Marks whether to enable acoustic echo cancellation.
The default value is true
(enable). If you wish not to enable the acoustic echo cancellation, set AEC
as false
.
Note
Safari does not support this setting.
Marks whether to enable audio gain control.
The default value is true
(enable). If you wish not to enable the audio gain control, set AGC
as false
.
Note
Safari does not support this setting.
Marks whether to enable automatic noise suppression.
The default value is true
(enable). If you wish not to enable automatic noise suppression, set ANS
as false
.
Note
ANS
as false
does not take effect on Firefox.Specifies the audio source of the stream.
The camera device ID retrieved from the getDevices method.
The retrieved ID is ASCII characters, and the string length is greater than or equals to 0 and less than 256 bytes.
When the string length is 0, this property is ignored.
The extension ID of the Chrome screen-sharing extension.
ASCII characters only, and the string length must be greater than 0 and less than 256 bytes.
Set this property if you use the Chrome screen-sharing extension. See Chrome Extension for Screen Sharing for details.
Note
Chrome 72 and later versions support screen sharing without the extension. You can leave extensionId
as empty.
If you set the extensionId
, then you need to use the screen-sharing extension.
Sets using the front or rear camera
You can set this parameter to use the front or rear camera on mobile devices:
"user"
: The front camera."environment"
: The rear camera.The screen-sharing mode on the Firefox browser.
If you are using the Firefox browser, setting this property specifies the screen-sharing mode:
"screen"
: (default) share the current screen"application"
: share all windows of an App"window"
: share a specified window of an AppNote
Firefox on Windows does not support the application mode.
See Screen Sharing on Firefox for details.
The microphone device ID retrieved from the getDevices method.
The retrieved ID is ASCII characters, and the string length is greater than or equals to 0 and less than 256 bytes.
When the string length is 0, this property is ignored.
Marks whether to mirror the local video image of the publisher in the local preview.
This setting does not take effect in screen-sharing streams.
true
: (Default) Mirror the local video.false
: Do not mirror the local video.Agora recommends enabling this function when using the front camera, and disabling it when using the rear camera.
Since
3.2.0
Sets the video transmission optimization strategy:
"motion"
: Prioritizes video smoothness. In most cases, the SDK does not reduce the frame rate, but may reduce the sending resolution."detail"
: Prioritizes clarity. In most cases, the SDK does not reduce the sending resolution, but may reduce the frame rate.If you leave this property empty, the SDK uses the default transmission optimization strategy:
screen
property as true
when calling createStream, the default transmission optimization strategy is to prioritizes clarity.Marks whether this stream contains a screen-sharing track. See Share the Screen for details.
Marks whether to share the audio playback when sharing the screen.
Since
3.0.0
true
: Share the local audio playback when sharing the screen.false
: (Default) Do not share the local audio playback when sharing the screen.To share the local audio playback when sharing the screen, ensure that you set screen as true
. We recommend also setting audio as false
. If both screenAudio
and audio
are set as true
, the stream only contains the local audio playback.
Note
The stream ID.
Please set the stream ID as the user ID, which can be retrieved from the callback of Client.join.
Marks whether this stream contains a video track.
Specifies the video source of the stream.
Note
If you use a video source created by the Canvas API, re-draw on the canvas every one second when the drawing is still to keep the video publishing.
A class defining the
spec
paramter in the createStream method.Create a Stream
You have two options to create an audio/video stream:
Set the audio, video, and screen properties
var stream = AgoraRTC.createStream({ streamID: uid, audio:true, video:true, screen:false });
Set the audioSource and videoSource properties
Compared with the first option, the audioSource and videoSource properties can specify the audio and video tracks for the stream. Use this option if you need to process the audio and video before creating the stream.
Use the
mediaStream
method to get the audio and video tracks fromMediaStreamTrack
, and then setaudioSource
andvideoSource
:navigator.mediaDevices.getUserMedia( {video: true, audio: true} ).then(function(mediaStream){ var videoSource = mediaStream.getVideoTracks()[0]; var audioSource = mediaStream.getAudioTracks()[0]; // After processing videoSource and audioSource var localStream = AgoraRTC.createStream({ video: true, audio: true, videoSource: videoSource, audioSource: audioSource }); localStream.init(function(){ client.publish(localStream, function(e){ //... }); }); });
Note:
MediaStreamTrack
refers to theMediaStreamTrack
object supported by the browser. See MediaStreamTrack API for details.Currently this option only supports the Chrome browser.