setRtmpShouldSendPings method

Future<void> setRtmpShouldSendPings(
  1. bool enabled
)

启用 RTMP 周期 ping,用于测量往返时延(RootEncoder 2.7.0+,仅 Android)。

须在 startVideoStreaming 之前调用;getStreamStatistics 中的 StreamStatistics.rttMicros 依赖此项。

Implementation

Future<void> setRtmpShouldSendPings(bool enabled) async {
  if (!value.isInitialized! || _isDisposed) {
    throw CameraException(
      'Uninitialized CameraController.',
      'setRtmpShouldSendPings was called on uninitialized CameraController',
    );
  }
  if (!Platform.isAndroid) {
    throw CameraException(
      'Unsupported platforms.',
      'setRtmpShouldSendPings is only supported on Android.',
    );
  }
  try {
    await _channel.invokeMethod<void>(
      'setRtmpShouldSendPings',
      <String, dynamic>{'enabled': enabled},
    );
  } on PlatformException catch (e) {
    throw CameraException(e.code, e.message);
  }
}