/*! @file trro_field_compat.h
 *
 * 【内部头文件 · 请勿对外发布】
 *
 * 本头文件仅供 SDK 内部编译使用（由 trro_field.cpp 包含），承载 2.4 gateway
 * 接口（TRRO_xxx 前缀 + 裸名 getErrorMsg）的兼容层声明。
 *
 * 对外发布目录 sdk_lib/include/ 中 **不应** 出现此文件；对外头文件只有
 * trro_field.h（仅暴露 2.5 TRROField_xxx 接口）与 trro_error_enum.h。
 *
 * --------------------------------------------------------------------------
 * 设计意图：让按 trro_gateway 2.4 接口（TRRO_xxx 前缀）开发的老客户，无需
 * 修改任何代码即可链接到 2.5 SDK。本块声明对应的符号实现见 trro_field.cpp
 * 末尾的 wrapper 块——它们只是对 2.5 实现 TRROField_xxx 的薄转发。
 *
 * 双 .so 产物分工：
 *   - libtrro_field.so（标准库）：
 *     同时导出 TRROField_xxx + TRRO_xxx 全集，常规客户使用。
 *   - libtrro_field_alone.so（推拉流共用客户专用）：
 *     链接时使用 cmake/trro_field_alone.ver，仅 TRROField_* 进入导出列表，
 *     TRRO_* 与 getErrorMsg 被 ld 强制 local 化，避免与同进程的拉流端
 *     SDK TRRO_ 前缀符号冲突。
 * --------------------------------------------------------------------------
 */
#ifndef TRRO_FIELD_COMPAT_H
#define TRRO_FIELD_COMPAT_H

#include "trro_field.h"   /* 复用 2.5 的 typedef、结构体、宏定义 */

/* -------- 1) 回调 typedef 别名（共 19 个） --------
 * 直接复用 2.5 typedef 的函数指针签名，避免重复定义带来的不一致。
 * typedef 不影响符号导出。
 */
typedef TRROField_onMultiNetworkStat            TRRO_onMultiNetworkStat;
typedef TRROField_OnAudioState                  TRRO_OnAudioState;
typedef TRROField_OnControlState                TRRO_OnControlState;
typedef TRROField_OnState                       TRRO_OnState;
typedef TRROField_OnErrorEvent                  TRRO_OnErrorEvent;
typedef TRROField_onControlData                 TRRO_onControlData;
typedef TRROField_onVideoCaptureData            TRRO_onVideoCaptureData;
typedef TRROField_onVideoEncodeData             TRRO_onVideoEncodeData;
typedef TRROField_OnLogData                     TRRO_OnLogData;
typedef TRROField_onEncodeFrameInfo             TRRO_onEncodeFrameInfo;
typedef TRROField_onLatencyReport               TRRO_onLatencyReport;
typedef TRROField_onMediaState                  TRRO_onMediaState;
typedef TRROField_onSignalState                 TRRO_onSignalState;
typedef TRROField_onOperationPermissionRequest  TRRO_onOperationPermissionRequest;
typedef TRROField_onVideoCaptureFrame           TRRO_onVideoCaptureFrame;
typedef TRROField_onRemoteMixAudioFrame         TRRO_onRemoteMixAudioFrame;
typedef TRROField_onRemoteEncodedFrameData      TRRO_onRemoteEncodedFrameData;
typedef TRROField_onRemoteDeviceState           TRRO_onRemoteDeviceState;
typedef TRROField_onActiveState                 TRRO_onActiveState;

/* -------- 2) 函数声明（共 62 个 TRRO_ 前缀 + 1 个裸 getErrorMsg） --------
 * 每个 wrapper 与 2.5 同名 TRROField_xxx 一一对应。详细语义参考 trro_field.h
 * 中对应 2.5 接口的注释。
 */

/* 错误码描述 */
extern "C" TRROCOMPAT_EXPORT const char* TRRO_getErrorMsg(int errorCode);
/* 裸名 getErrorMsg：2.4 SDK 历史导出名，保留以兼容老客户 */
extern "C" TRROCOMPAT_EXPORT const char* getErrorMsg(int errorCode);

/* 初始化与停止 */
extern "C" TRROCOMPAT_EXPORT int  TRRO_initGwJsonWithLicense(const char* json_str, const char* license_path, int mode = 0);
extern "C" TRROCOMPAT_EXPORT int  TRRO_initGwJson(const char* json_str, int mode = 0);
extern "C" TRROCOMPAT_EXPORT int  TRRO_initGwPathWithLicense(const char* cfg_path, const char* license_path, int mode = 0);
extern "C" TRROCOMPAT_EXPORT int  TRRO_initGwPath(const char* cfg_path, int mode = 0);
extern "C" TRROCOMPAT_EXPORT int  TRRO_start();
extern "C" TRROCOMPAT_EXPORT void TRRO_stop();
extern "C" TRROCOMPAT_EXPORT int  TRRO_updatePassword(const char* password, int length);

/* 控制数据通道 */
extern "C" TRROCOMPAT_EXPORT DEPRECATED int TRRO_sendControlData(const char* msg, int len, int qos = 0);
extern "C" TRROCOMPAT_EXPORT int  TRRO_sendControlDataV2(const char* target, const char* msg, int len, int qos = 0, int channel = 0, int options = 0);

/* 字幕渲染 */
extern "C" TRROCOMPAT_EXPORT void TRRO_setChineseFontAndSize(const char* font_path, float size, const char* input);

/* 外部视频/编码流输入 */
extern "C" TRROCOMPAT_EXPORT DEPRECATED int TRRO_externalVideoData(int stream_id, const char* data, int width, int height, int type, int dataSize = 0, const char* text = "", int point_x = 0, int point_y = 0);
extern "C" TRROCOMPAT_EXPORT int  TRRO_externalVideoDataWithText(int stream_id, const char* data, int width, int height, int type, int dataSize = 0, TRRO_TextFormat* text_format = NULL);
extern "C" TRROCOMPAT_EXPORT int  TRRO_externalCombineVideodata(int stream_id, int capture_id, const char* data, int width, int height, int type, int dataSize = 0, TRRO_TextFormat* text_format = NULL);
extern "C" TRROCOMPAT_EXPORT int  TRRO_externalVideoDataWithUserTime(int stream_id, const char* data, int width, int height, int type, long long user_time, int dataSize = 0);
extern "C" TRROCOMPAT_EXPORT int  TRRO_externalEncodeVideoData(int stream_id, const char* data, int width, int height, int size, int type);
extern "C" TRROCOMPAT_EXPORT int  TRRO_externalEncodeVideoDataUserTime(int stream_id, const char* data, int width, int height, int size, FrameFieldType type, long long user_time);

/* 远端设备权限/网络评估 */
extern "C" TRROCOMPAT_EXPORT int  TRRO_setOperationPermission(const char* remote_devid, int permission);
extern "C" TRROCOMPAT_EXPORT int  TRRO_testNetworkQuality(int* stream_ids, int stream_size, int test_time);

/* 各类回调注册 */
extern "C" TRROCOMPAT_EXPORT int  TRRO_registerMultiNetworkStatsCallback(void* context, TRRO_onMultiNetworkStat* callback);
extern "C" TRROCOMPAT_EXPORT int  TRRO_registerControlDataCallback(void* context, TRRO_onControlData* callback);
extern "C" TRROCOMPAT_EXPORT int  TRRO_registerVideoCaptureCallback(void* context, TRRO_onVideoCaptureData* callback);
extern "C" TRROCOMPAT_EXPORT int  TRRO_registerVideoEncodeCallback(void* context, TRRO_onVideoEncodeData* callback);
extern "C" TRROCOMPAT_EXPORT int  TRRO_enableVideoEncode(int stream_id, int enable);
extern "C" TRROCOMPAT_EXPORT int  TRRO_forceKeyFrame(int stream_id);
extern "C" TRROCOMPAT_EXPORT int  TRRO_registerEncodeFrameInfoCallback(void* context, TRRO_onEncodeFrameInfo* callback);
extern "C" TRROCOMPAT_EXPORT int  TRRO_registerRemoteMixAudioFrameCallback(void* context, TRRO_onRemoteMixAudioFrame* callback);
extern "C" TRROCOMPAT_EXPORT int  TRRO_registerRemoteEncodedFrameCallback(void* context, TRRO_onRemoteEncodedFrameData* callback);
extern "C" TRROCOMPAT_EXPORT int  TRRO_registerOnState(void* context, TRRO_OnState* callback);
extern "C" TRROCOMPAT_EXPORT int  TRRO_registerOnAudioState(void* context, TRRO_OnAudioState* callback);
extern "C" TRROCOMPAT_EXPORT int  TRRO_registerOnControlState(void* context, TRRO_OnControlState* callback);
extern "C" TRROCOMPAT_EXPORT int  TRRO_registerOnErrorEvent(void* context, TRRO_OnErrorEvent* callback);
extern "C" TRROCOMPAT_EXPORT int  TRRO_registerLogCallback(void* context, TRRO_OnLogData* callback);
extern "C" TRROCOMPAT_EXPORT int  TRRO_registerLatencyCallback(void* context, TRRO_onLatencyReport* callback);
extern "C" TRROCOMPAT_EXPORT int  TRRO_registerMediaState(void* context, TRRO_onMediaState* callback);
extern "C" TRROCOMPAT_EXPORT int  TRRO_registerAudioMediaState(void* context, TRRO_onMediaState* callback);
extern "C" TRROCOMPAT_EXPORT int  TRRO_registerSignalStateCallback(void* context, TRRO_onSignalState* callback);
extern "C" TRROCOMPAT_EXPORT int  TRRO_registerOperationPermissionRequest(void* context, TRRO_onOperationPermissionRequest* callback);
extern "C" TRROCOMPAT_EXPORT int  TRRO_registerRemoteDeviceState(void* context, TRRO_onRemoteDeviceState* callback);
extern "C" TRROCOMPAT_EXPORT int  TRRO_registerActiveState(void* context, TRRO_onActiveState* callback);

/* 录制 */
extern "C" TRROCOMPAT_EXPORT int  TRRO_startRecorder(int recorderID, int format, int width, int heigh, int jump, int fps, int bps, const char* filename, const char* config);
extern "C" TRROCOMPAT_EXPORT int  TRRO_sendRecordVideoData(int recorderID, const char* data, int width, int height, int format);
extern "C" TRROCOMPAT_EXPORT int  TRRO_switchRecorderFile(int recorderID, const char* filename);
extern "C" TRROCOMPAT_EXPORT int  TRRO_stopRecorder(int recorderID);

/* 推流/编码控制 */
extern "C" TRROCOMPAT_EXPORT int  TRRO_setForcePush(int stream_id, bool force_push);
extern "C" TRROCOMPAT_EXPORT int  TRRO_externalVideoDataNv(int stream_id, const char* data, int real_width, int real_height, int type);
extern "C" TRROCOMPAT_EXPORT int  TRRO_externalVideoDataDmaNative(int stream_id, int fd, int real_width, int real_height, int type);
extern "C" TRROCOMPAT_EXPORT int  TRRO_externVideoMJPEGDecode(int stream_id, const char* data, int data_size, int width, int height);

/* 音频 */
extern "C" TRROCOMPAT_EXPORT int  TRRO_externAudioData(const char* data, int data_size, int channel, int sample_rate);
extern "C" TRROCOMPAT_EXPORT int  TRRO_externAudioDataUserTime(const char* data, int data_size, int channel, int sample_rate, unsigned long long user_time);
extern "C" TRROCOMPAT_EXPORT int  TRRO_audioMute(const char* userid, bool mute);
extern "C" TRROCOMPAT_EXPORT int  TRRO_muteLocalAudio(bool mute);
extern "C" TRROCOMPAT_EXPORT int  TRRO_muteLocalVideo(bool mute, int stream_id);

/* 会话/RTC/版本/设备/采集/编码 ROI */
extern "C" TRROCOMPAT_EXPORT int  TRRO_setSessionActiveState(bool is_active);
extern "C" TRROCOMPAT_EXPORT int  TRRO_reinitRtc(const char* config);
extern "C" TRROCOMPAT_EXPORT const char* TRRO_getSdkVersion();
extern "C" TRROCOMPAT_EXPORT int  TRRO_getDeviceCount(Trro_MediaFieldDeviceType type);
extern "C" TRROCOMPAT_EXPORT const char* TRRO_getDeviceName(Trro_MediaFieldDeviceType type, int index);
extern "C" TRROCOMPAT_EXPORT int  TRRO_setCurrentDevice(Trro_MediaFieldDeviceType type, int index);
extern "C" TRROCOMPAT_EXPORT int  TRRO_startVideoCapture(void* context, const char* url, Trro_VideoCaptureProtocol protocol, int color_format, int width, int height, int fps, TRRO_onVideoCaptureFrame callback, unsigned long long* capture_id);
extern "C" TRROCOMPAT_EXPORT int  TRRO_stopVideoCapture(unsigned long long capture_id);
extern "C" TRROCOMPAT_EXPORT int  TRRO_setEncodeRoi(int stream_id, TRRO_RoiRect* roi_rects, int len);

#endif /* TRRO_FIELD_COMPAT_H */
