Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In order to support BlueTooth SCO headsets

1. Configure the sample rate overrides for recording and playback to values that are required by SCO:

Code Block
languagejs
    try {
      Os.setenv("PHENIX_AUDIO_PLAYBACK_SAMPLE_RATE_OVERRIDE", "16000", true);
      Os.setenv("PHENIX_AUDIO_RECORDING_SAMPLE_RATE_OVERRIDE", "8000", true);
    } catch (ErrnoException e) {
      // handle exception
    }

2. Enable SCO in the AudioManager (this example assumes the code is placed in your Application subclass):

Code Block
    AudioManager audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);

    // call at appropriate time - detection of BT on
    audioManager.startBluetoothSco();

    // call at appropriate time - detection of BT off
    audioManager.stopBluetoothSco();

3. For both publishing and subscribing, make sure that audio echo cancellation is enabled in the respective options:

Code Block
    // publishing
    final UserMediaOptions mediaConstraints = new UserMediaOptions();
    mediaConstraints.getAudioOptions().capabilityConstraints.put(
            DeviceCapability.AUDIO_ECHO_CANCELATION_MODE,
            singletonList(new DeviceConstraint(AudioEchoCancelationMode.ON)));
    PublishOptions publishOptions = PCastExpressFactory.createPublishOptionsBuilder()
        .withMediaConstraints(mediaConstraints)
        // add any other options
        .buildPublishOptions();
    // subscribing
    final RendererOptions rendererOptions = new RendererOptions();
    rendererOptions.audioEchoCancelationMode = AudioEchoCancelationMode.ON;
    JoinChannelOptionsBuilder joinChannelOptionsBuilder = ChannelExpressFactory
        .createJoinChannelOptionsBuilder()
        .withRendererOptions(rendererOptions)
        // add any other options
        .buildJoinChannelOptions()

4. Note that only mono streams are supported by SCO.

...