Einstellungen des Herausgebers

Übersicht

Die Vonage Video Client SDKs ermöglichen es den Teilnehmern, Audio und Video in einer Sitzung zu veröffentlichen. Die Client-SDKs ermöglichen die Konfiguration des Publisher-Objekts auf der Grundlage Ihrer Präferenzen und Ihres Anwendungsfalls.

In dieser Anleitung wird das Thema behandelt:

  • Nur Audio oder Video veröffentlichen
  • Ändern der Videoeinstellungen eines Herausgebers
  • Ändern der Audioeinstellungen eines Verlags

Nur Audio oder Video veröffentlichen

Wenn Sie ein Publisher-Objekt erstellenkönnen Sie festlegen, ob zunächst nur Audio oder nur Video veröffentlicht werden soll. Der folgende Code erstellt zum Beispiel einen reinen Audio-Publisher:

To toggle audio and video on and off, set the publishAudio and publishVideo properties of the properties prop passed into the OTPublisher component:

<OTPublisher
  properties={{
    publishAudio: true,
    publishVideo: false,
  }}
/>

By default, these are set to true (both audio and video are published).

Sobald Sie ein Publisher-Objekt erstellt haben, können Sie Audio und Video ein- oder ausschalten, indem Sie die Funktion publishAudio() und publishVideo() Methoden (Übergabe eines booleschen Wertes). Der folgende Code schaltet zum Beispiel Audio aus:

publisher.publishAudio(false);

Wenn Sie Audio oder Video ein- oder ausschalten, sendet das Session-Objekt in jedem verbundenen Client eine streamPropertyChanged Ereignis. Es gibt auch eine Reihe von Optimierungen der Benutzeroberfläche, die Sie in einer reinen Sprachsitzung vornehmen können. Siehe die Stimme Leitfaden.

Veröffentlichung in einer reinen Sprachsitzung

Um eine reine Sprachsitzung einzurichten, setzen Sie die videoSource Eigenschaft zu null oder false wenn Sie jedes Publisher-Objekt in der Sitzung erstellen. Der folgende Code erstellt zum Beispiel einen Publisher für eine reine Sprachsitzung:

<OTPublisher
  properties={{
    videoTrack: false,
  }}
/>

Wenn Sie die Einstellung videoSource Eigenschaft zu nullfordert der Veröffentlichungs-Client keinen Zugriff auf die Kamera an, und es wird kein Video veröffentlicht.

Veröffentlichung von Audio nur für Publisher mit geringer Bandbreite

Publisher können so konfiguriert werden, dass sie in Situationen mit geringer Bandbreite das Video deaktivieren, während das Audio aktiviert bleibt. Die Videoveröffentlichung wird wieder aufgenommen, wenn sich die Bandbreite des Publishers verbessert.

Weitere Informationen finden Sie in der Audio-Fallback Leitfaden für Entwickler.

Ändern der Videoeinstellungen eines Publishers

Einstellen der Auflösung und Bildrate für ein Video

To set a recommended video resolution for a published stream, set the resolution property of the properties prop of the OTPublisher component:

<OTPublisher
  properties={{
    resolution: '1280x720',
  }}
/>

This resolution property is a string, defining the desired resolution of the video. The format of the string is "widthxheight", where the width and height are represented in pixels. Valid values are "1920x1080", "1280x720", "640x480", and "320x240".

The default resolution for a stream (if you do not specify a resolution) is 640x480 pixels. If the client system cannot support the resolution you requested, the stream will use the next largest setting supported.

It is best to try to match the resolution to the size that the video will be displayed. If you are only displaying the video at 320x240 pixels then there is no point in streaming at 1280x720 or 1920x1080. Reducing the resolution can save bandwidth and reduce congestion and connection drops.

Note: See the 1080p developer guide for considerations about using 1080p resolution.

To set a recommended frame rate for a published stream, set the frameRate property of the properties prop of the OTPublisher component:

<OTPublisher
  properties={{
    frameRate: 7,
  }}
/>

Set the value to the desired frame rate, in frames per second, of the video. Valid values are 30 (the default), 15, 7, and 1.

Aktivieren der Kamerataschenlampe (Blitzlicht)

Set the cameraTorch property of the object passed in as the properties prop of the OTPublisher object to enable or disable the camera flashlight (torch) while capturing video:

<OTPublisher
  properties={{
    cameraTorch: false,
  }}
/>

The default value is false (the flashlight is not used).

Note the not all device cameras have a camera flashlight. If the active camera does not support camera flashlight functionality (for example, the front camera typically does not support it), setting cameraTorch has no effect.

Einstellen des Kamerazooms

Set the cameraZoomFactor property of the object passed in as the properties prop of the OTPublisher object to set the camera zoom ratio (factor):

<OTPublisher
  properties={{
    cameraZoomFactor: 0.7,
  }}
/>

The ratio/factor value ranges from 0.5 to the maximum zoom factor. Values between 0.5 and 1.0 represent ultra-wide-angle (zoom out), and values between 1.0 and the maximum zoom factor represent zooming in. The actual zoom factor applied is clamped to the range supported by the active camera's configuration — if the camera does not support ultra-wide-angle, zoom factors set below 1.0 will not take effect and no zoom will be applied. For values over the maximum zoom factor supported by the camera, the zoom factor will be set to the maximum supported value.

Umschalten der von einem Verlag verwendeten Kamera

You can have the publisher use the rear-facing camera of the device by setting a properties prop of the OTPublisher component and setting the cameraPosition property of that object to "back":

<OTPublisher
  properties={{
    cameraPosition: 'back',
  }}
/>

Spiegeln der lokalen Anzeige des Videos eines Herausgebers

You can set the mirror property of the options passed into the OT.initPublisher() method to have the publisher's locally rendered video mirrored (true) or not (false). By default, video is mirrored for a publisher that has a camera video source, and not mirrored for a screen-sharing video.

This setting only affects the rendered video in the publisher's client application. It has no effect on the video in subscribing clients.

Ändern der Audioeinstellungen eines Publishers

Umschalten der von einem Publisher verwendeten Audioquelle

You can switch the microphone or MediaStreamTrack object used as the audio source for a Publisher by calling the setAudioSource() method of the Publisher object.

Pass a device ID for a microphone or an audio MediaStreamTrack object into the Publisher.setAudioSource() method. The method returns a Promise that is rejected on error (see the reference documentation for setAudioSource()).

For example, the following code shows you how to implement a cycleMicrophone() function that cycles through the microphones available:

// Setting an audio source to a new MediaStreamTrack
const stream = await OT.getUserMedia({
  videoSource: null,
});

const [audioSource] = stream.getAudioTracks();
publisher.setAudioSource(audioSource).then(() => console.log('Audio source updated'));

// Cycling through microphone inputs
let audioInputs;
let currentIndex = 0;
OT.getDevices((err, devices) => {
  audioInputs = devices.filter(device => device.kind === 'audioInput');
  // Find the right starting index for cycleMicrophone
  audioInputs.forEach((device, idx) => {
    if (device.label === publisher.getAudioSource().label) {
      currentIndex = idx;
    }
  });
});

const cycleMicrophone = () => {
  currentIndex += 1;
  let deviceId = audioInputs[currentIndex % audioInputs.length].deviceId;
  publisher.setAudioSource(deviceId);
};

The Publisher.setAudioSource() method only works for a publisher that has an audio source. If you set audioSource to null (or false) when calling OT.initPublisher(), you cannot later add an audio source to the publisher.

The Publisher.getAudioSource() method returns the MediaStreamTrack object used as the current audio input source for the publisher.

The OT.getDevices() method enumerates the audio and video input devices available to the browser.

Erkennen, wenn ein Publisher das Audioeingabegerät wechselt (Web)

Standardmäßig übernimmt das SDK automatisch den Wechsel des Audioeingabegeräts für jedes Publisher-Objekt, wenn ein Audioeingabegerät hinzugefügt oder entfernt wird, es sei denn, die Verwaltung von Audioeingabegeräten wurde deaktiviert. Siehe Deaktivieren der standardmäßigen Verwaltung von Audio-Eingabegeräten wenn Sie den automatischen Wechsel des Audioeingangsgeräts deaktivieren möchten.

Das Publisher-Objekt sendet eine audioInputDeviceChanged Ereignis, wenn das SDK automatisch die Audioeingabe ändert. Dieses Ereignis wird ausgelöst, wenn ein neues Audio-Eingabegerät hinzugefügt wird, das aktuelle Audio-Eingabegerät entfernt wird oder wenn das Betriebssystem des Publishers die Audio-Eingabegeräte wechselt. Das ausgelöste Ereignis hat eine device Eigenschaft, die Informationen über das Audio-Eingabegerät enthält. Vielleicht möchten Sie Ihren Benutzern mitteilen, dass sich ihr Mikrofon geändert hat:

publisher.on('audioInputDeviceChanged', (event) => {
  console.log('audio input device', event.device);
  console.log(`changing device to: ${event.device.label}`);
});

Umschalten des von einem Publisher verwendeten Audioausgangs

You can switch the audio output device (a speaker or headphones) used to play audio from all publishers and subscribers (in all Vonage Video sessions in the browser).

The OT.getAudioOutputDevices() method enumerates the audio and video input devices available to the browser.

The OT.getActiveAudioOutputDevice() method identifies the currently active audio output device.

Use the OT.setAudioOutputDevice() method to set the audio output device.

For example, the following code shows you how to implement a cycleAudioOutput() function that cycles through the available audio output devices:

// Cycling through audio output devices
let currentIndex = 0;
const audioOutputs = await OT.getAudioOutputDevices();
const currentOutputDevice = await OT.getActiveAudioOutputDevice();
audioOutputs.forEach((device, index) => {
  if (device.label === currentOutputDevice.label) {
    currentIndex = index;
  }
});

const cycleAudioOutput = async () => {
  currentIndex += 1;
  let deviceId = audioOutputs[currentIndex % audioOutputs.length].deviceId;
  await OT.setAudioOutputDevice(deviceId);
};

Abstimmung der Audioqualität

To set the audio bitrate for a publisher's audio stream, set the audioBitrate property of the properties prop passed into the OTPublisher component:

<OTPublisher
  properties={{
    audioBitrate: 48000,
  }}
/>

The audioBitrate setting is the desired bitrate for the published audio, in bits per second. The supported range of values is 6,000 - 510,000. Set this value to enable high-quality audio (or to reduce bandwidth usage with lower-quality audio).

The following are recommended settings:

  • 8,000 - 12,000 for narrowband (NB) speech
  • 16,000 - 20,000 for wideband (WB) speech
  • 28,000 - 40,000 for full-band (FB) speech
  • 48,000 - 64,000 for full-band (FB) music

Reduzierung der Audiobandbreite mit Opus DTX

Opus DTX (Diskontinuierliche Übertragung) ist ein Audiocodec, der die Bandbreitennutzung reduzieren kann, wenn ein Teilnehmer nicht spricht. Dies kann in großen Sitzungen mit vielen Audioteilnehmern nützlich sein.

Sie aktivieren Opus DTX durch Setzen des Parameters enableDtx Eigenschaft als Initialisierung eines Publishers. Weitere Informationen finden Sie hier Vonage Video API Wissensbasisartikel.