Velocidad de bits máxima del editor
Este tema incluye información detallada sobre cómo configurar la tasa de bits máxima de vídeo mediante el Client SDK del cliente de Vonage Video para Linux:
- Configuración y recuperación de un preajuste
- Establecer y recuperar un valor de velocidad de bits sin procesar
- Casos especiales
Para obtener una descripción general de la API de velocidad de bits máxima del editor, consulta este tema.
Configuración y recuperación de un preajuste
El otc_video_bitrate_preset enum, en el publisher.h incluye valores preestablecidos:
OTC_VIDEO_BITRATE_PRESET_DEFAULTOTC_VIDEO_BITRATE_PRESET_BW_SAVEROTC_VIDEO_BITRATE_PRESET_EXTRA_BW_SAVEROTC_VIDEO_BITRATE_PRESET_CUSTOM
Véase Preajustes de velocidad de bits de vídeo para más detalles sobre estos preajustes.
Para recuperar la tasa de bits de vídeo actualmente configurada para un editor determinado, llame a la función otc_publisher_get_video_bitrate_preset() función:
enum otc_video_bitrate_preset preset = otc_publisher_get_video_bitrate_preset(publisher);
if (preset == OTC_VIDEO_BITRATE_PRESET_BW_SAVER) {
printf("The publisher is using the BW_SAVER preset.\n");
}
Para configurar un preajuste, llama a la función otc_publisher_set_video_bitrate_preset() función. Esta función tiene dos parámetros:
publisher— Un puntero a la instancia de otc_publisher.preset- Un valor deotc_video_bitrate_preset. No utilizarOTC_VIDEO_BITRATE_PRESET_CUSTOM.
La función devuelve uno de estos valores:
OTC_SUCCESS- El preajuste se ha aplicado correctamente.OTC_ERROR_INVALID_PARAMETER— El editor proporcionado es NULL o la configuración predeterminada no es válida.
Ejemplo:
otc_status status = otc_publisher_set_video_bitrate_preset(publisher, OTC_VIDEO_BITRATE_PRESET_BW_SAVER);
if (status == OTC_SUCCESS) {
printf("Bitrate preset successfully set to BW_SAVER.\n");
} else {
printf("Failed to set bitrate preset.\n");
}
Establecer y recuperar un valor de velocidad de bits sin procesar
Si los preajustes predefinidos no son adecuados, puedes establecer manualmente un valor de tasa de bits brutos personalizado.
Para obtener la tasa de bits de vídeo máxima establecida actualmente para un editor, llame a la función otc_publisher_get_max_video_bitrate() función. Devuelve la tasa de bits máxima establecida actualmente (en bits por segundo). Si no se establece ningún valor personalizado, la función devuelve 0.
Ejemplo:
int max_bitrate = otc_publisher_get_max_video_bitrate(publisher);
printf("Current max video bitrate: %d bps\n", max_bitrate);
Para establecer un valor de velocidad de bits máxima personalizada (en lugar de una preajustada), utiliza la otc_publisher_set_max_video_bitrate() función. Esta función tiene los siguientes parámetros:
publisher- Un puntero a una instancia existente de otc_publisher.bitrate_bps— La tasa de bits máxima deseada (en bits por segundo). Debe estar comprendida entre 5.000 y 10.000.000.
La función devuelve uno de los siguientes valores:
OTC_SUCCESS— La tasa de bits se ha aplicado correctamente.OTC_ERROR_INVALID_PARAMETER— El puntero del editor esNULL, obitrate_bpsestá fuera de alcance.
Ejemplo:
int new_bitrate = 300000; // 300 kbps
otc_status status = otc_publisher_set_max_video_bitrate(publisher, new_bitrate);
if (status == OTC_SUCCESS) {
printf("Successfully set max video bitrate to %d bps.\n", new_bitrate);
} else {
printf("Failed to set max video bitrate.\n");
}
Véase Ajuste de los valores de la tasa de bits bruta Para más información.
Casos especiales
Al establecer el valor de la tasa de bits bruta en 0 se elimina cualquier limitación de la tasa de bits establecida previamente, volviendo al comportamiento predeterminado.
const int zero_bitrate = 0; // no limitations
const int new_bitrate = 300000; // 300 kbps
otc_status status = otc_publisher_set_max_video_bitrate(publisher, new_bitrate);
if (status == OTC_SUCCESS) {
assert(otc_publisher_get_max_video_bitrate(publisher) == new_bitrate);
}
status = otc_publisher_set_max_video_bitrate(publisher, zero_bitrate);
if (status == OTC_SUCCESS) {
assert(otc_publisher_get_max_video_bitrate(publisher) == zero_bitrate);
}
Al llamar al (otc_publisher_get_video_bitrate_preset()) La función, tras establecer una tasa de bits personalizada, devuelve OTC_VIDEO_BITRATE_PRESET_CUSTOM.
const int new_bitrate = 1000000; // 1 mbps
otc_status status = otc_publisher_set_max_video_bitrate(publisher, new_bitrate);
if (status == OTC_SUCCESS) {
assert(otc_publisher_get_video_bitrate_preset(publisher) == OTC_VIDEO_BITRATE_PRESET_CUSTOM);
}
status = otc_publisher_set_max_video_bitrate(publisher, zero_bitrate);
if (status == OTC_SUCCESS) {
assert(otc_publisher_get_video_bitrate_preset(publisher) == OTC_VIDEO_BITRATE_PRESET_DEFAULT);
}
El indicador de tasa de bits bruta devuelve 0 cuando el editor utiliza un preajuste.
// Assume all the statuses are OTC_SUCCESS
int bitrate_bps = otc_publisher_get_max_video_bitrate(publisher);
assert(bitrate_bps == 0);
otc_publisher_set_video_bitrate_preset(publisher, OTC_VIDEO_BITRATE_PRESET_BW_SAVER);
bitrate_bps = otc_publisher_get_max_video_bitrate(publisher);
assert(bitrate_bps == 0);
otc_publisher_set_video_bitrate_preset(publisher, OTC_VIDEO_BITRATE_PRESET_EXTRA_BW_SAVER);
bitrate_bps = otc_publisher_get_max_video_bitrate(publisher);
assert(bitrate_bps == 0);
otc_publisher_set_max_video_bitrate(publisher, 200000);
bitrate_bps = otc_publisher_get_max_video_bitrate(publisher);
assert(bitrate_bps == 200000);
otc_publisher_set_video_bitrate_preset(publisher, OTC_VIDEO_BITRATE_PRESET_DEFAULT);
bitrate_bps = otc_publisher_get_max_video_bitrate(publisher);
assert(bitrate_bps == 0);