From 7f7fef1ccb88f354bcd44b6a8cfe5acab302c702 Mon Sep 17 00:00:00 2001 From: gxz Date: Tue, 9 Jan 2024 18:05:18 +0800 Subject: [PATCH] chore: send uStride and vStride when call GetVideoFrameCache --- source_code/agora_node_ext/agora_electron_bridge.cpp | 10 ++++++++++ ts/Renderer/RendererManager.ts | 12 +++++++++--- ts/Renderer/YUVCanvasRenderer/index.ts | 2 ++ ts/Types.ts | 10 ++++++++++ 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/source_code/agora_node_ext/agora_electron_bridge.cpp b/source_code/agora_node_ext/agora_electron_bridge.cpp index 1030bf187..83b471c5e 100644 --- a/source_code/agora_node_ext/agora_electron_bridge.cpp +++ b/source_code/agora_node_ext/agora_electron_bridge.cpp @@ -392,6 +392,9 @@ napi_value AgoraElectronBridge::GetVideoFrame(napi_env env, int height; int width; int yStride; + int uStride; + int vStride; + napi_obj_get_property(env, obj, "uid", config.uid); napi_obj_get_property(env, obj, "videoSourceType", config.video_source_type); @@ -410,6 +413,9 @@ napi_value AgoraElectronBridge::GetVideoFrame(napi_env env, napi_obj_get_property(env, obj, "height", height); napi_obj_get_property(env, obj, "width", width); napi_obj_get_property(env, obj, "yStride", yStride); + napi_obj_get_property(env, obj, "uStride", uStride); + napi_obj_get_property(env, obj, "vStride", vStride); + IrisCVideoFrame videoFrame; videoFrame.yBuffer = (uint8_t *) y_buffer; @@ -418,6 +424,8 @@ napi_value AgoraElectronBridge::GetVideoFrame(napi_env env, videoFrame.height = height; videoFrame.width = width; videoFrame.yStride = yStride; + videoFrame.uStride = uStride; + videoFrame.vStride = vStride; videoFrame.metadata_buffer = nullptr; videoFrame.metadata_size = 0; videoFrame.alphaBuffer = nullptr; @@ -442,6 +450,8 @@ napi_value AgoraElectronBridge::GetVideoFrame(napi_env env, napi_obj_set_property(env, retObj, "width", videoFrame.width); napi_obj_set_property(env, retObj, "height", videoFrame.height); napi_obj_set_property(env, retObj, "yStride", videoFrame.yStride); + napi_obj_set_property(env, retObj, "uStride", videoFrame.uStride); + napi_obj_set_property(env, retObj, "vStride", videoFrame.vStride); napi_obj_set_property(env, retObj, "rotation", rotation); napi_obj_set_property(env, retObj, "timestamp", videoFrame.renderTimeMs); return retObj; diff --git a/ts/Renderer/RendererManager.ts b/ts/Renderer/RendererManager.ts index 2888eb8df..1c06674ef 100644 --- a/ts/Renderer/RendererManager.ts +++ b/ts/Renderer/RendererManager.ts @@ -373,14 +373,16 @@ export class RendererManager extends IRendererManager { break; case 1: { // GET_VIDEO_FRAME_CACHE_RETURN_TYPE::RESIZED - const { width, height, yStride } = finalResult; + const { width, height, yStride, uStride, vStride } = finalResult; const newShareVideoFrame = this.resizeShareVideoFrame( videoSourceType, channelId, uid, width, height, - yStride + yStride, + uStride, + vStride ); rendererItem.shareVideoFrame = newShareVideoFrame; finalResult = this.msgBridge.GetVideoFrame(newShareVideoFrame); @@ -621,7 +623,9 @@ export class RendererManager extends IRendererManager { uid: number, width = 0, height = 0, - yStride = 0 + yStride = 0, + uStride = 0, + vStride = 0 ): ShareVideoFrame { return { videoSourceType, @@ -633,6 +637,8 @@ export class RendererManager extends IRendererManager { width, height, yStride, + uStride, + vStride, }; } diff --git a/ts/Renderer/YUVCanvasRenderer/index.ts b/ts/Renderer/YUVCanvasRenderer/index.ts index 6b6f9b343..49ba78a2d 100644 --- a/ts/Renderer/YUVCanvasRenderer/index.ts +++ b/ts/Renderer/YUVCanvasRenderer/index.ts @@ -19,6 +19,8 @@ export class YUVCanvasRenderer extends IRenderer { width: 0, height: 0, yStride: 0, + uStride: 0, + vStride: 0, yBuffer: new Uint8Array(0), uBuffer: new Uint8Array(0), vBuffer: new Uint8Array(0), diff --git a/ts/Types.ts b/ts/Types.ts index 6dfb77f4e..ecf1a4e99 100644 --- a/ts/Types.ts +++ b/ts/Types.ts @@ -181,6 +181,14 @@ export interface ShareVideoFrame { * @ignore */ yStride: number; + /** + * @ignore + */ + uStride: number; + /** + * @ignore + */ + vStride: number; /** * @ignore */ @@ -270,6 +278,8 @@ export interface AgoraElectronBridge { ret: number; isNewFrame: boolean; yStride: number; + uStride: number; + vStride: number; width: number; height: number; rotation: number;