已合并
add band width compression doc #117569
sunchao106创建于 2025年11月21日
add band width compression doc #117569
已合并
sunchao106创建于 2025年11月21日
共 1 个文件变更+76-0
@@ -580,3 +580,79 @@ function stopPreviewOutput(previewOutput: camera.PreviewOutput): void {
580}580}
581```581```
582 582 
583+## isBandwidthCompressionSupported<sup>23+</sup>
584+ 
585+isBandwidthCompressionSupported(): boolean
586+ 
587+检查是否支持预览带宽压缩(指通过编码减少数据量,降低其在传输链路中的带宽占用)。
7
777_cc2025年11月25日

检查设备是否支持还是检查系统?

likedislike
588+ 
589+**原子化服务API:** 从API version 23开始,该接口支持在原子化服务中使用。
590+ 
591+**系统能力:** SystemCapability.Multimedia.Camera.Core
592+ 
593+**返回值:**
594+ 
595+| 类型 | 说明 |
596+| -------------- | ----------------------- |
597+| boolean | 是否支持预览带宽压缩。true表示支持,false表示不支持。 |
598+ 
599+**示例:**
600+ 
601+```ts
602+import { BusinessError } from '@kit.BasicServicesKit';
603+ 
604+function isBandwidthCompressionSupported(previewOutput: camera.PreviewOutput): boolean {
605+ let supported: boolean = false;
606+ try {
607+ supported = previewOutput.isBandwidthCompressionSupported();
608+ } catch (error) {
609+ // 失败返回错误码error.code并处理。
610+ let err = error as BusinessError;
611+ console.error(`The previewOutput.isBandwidthCompressionSupported call failed. error code: ${err.code}`);
612+ }
613+ return supported;
614+}
615+```
616+ 
617+## enableBandwidthCompression<sup>23+</sup>
618+ 
619+enableBandwidthCompression(enabled: boolean): void
620+ 
621+使能预览带宽压缩。
622+ 
623+使能之前,可先使用方法[isBandwidthCompressionSupported](#isbandwidthcompressionsupported23)对设备是否支持预览带宽压缩进行检查。
624+ 
625+**原子化服务API:** 从API version 23开始,该接口支持在原子化服务中使用。
626+ 
627+**系统能力:** SystemCapability.Multimedia.Camera.Core
628+ 
629+**参数:**
630+ 
631+| 参数名 | 类型 | 必填 | 说明 |
632+| -------- | ---------------------- | ---- | ------------------------------------------ |
633+| enabled | boolean | 是 | 是否使能预览带宽压缩。true表示使能,false表示不使能。 |
634+ 
635+**错误码:**
636+ 
637+以下错误码的详细介绍请参见[Camera错误码](errorcode-camera.md)。
638+ 
639+| 错误码ID | 错误信息 |
640+| -------- |----------------------------------------------- |
641+| 7400103 | Session not config. |
642+| 7400201 | Camera service fatal error. |
643+ 
644+**示例:**
645+ 
646+```ts
647+import { BusinessError } from '@kit.BasicServicesKit';
648+ 
649+function enableBandwidthCompression(previewOutput: camera.PreviewOutput, enabled: boolean): void {
650+ try {
651+ previewOutput.enableBandwidthCompression(enabled);
652+ } catch (error) {
653+ // 失败返回错误码error.code并处理。
654+ let err = error as BusinessError;
655+ console.error(`The previewOutput.enableBandwidthCompression call failed. error code: ${err.code}`);
656+ }
657+}
658+```