该工程的位置在:https://github.com/dropbox/djinni
现在分析djinni接口的优点和缺点:
优点:可以编写一份idl 文件生成所有平台的接口。
缺点:性能不高,数据使用std::vector<int8_t> 拷贝导致性能有很大损失。
具体demo可以参考:
@import "media.djinni" //引入其它idl 文件
@import "comm.djinni"
sdk_vendor = enum { //定义枚举类型
TENCENT;
AGORA;
HUAWEI;
ZEGO;
}
link_state = enum {
CONNECTING;
CONNECTED;
UNCONNECTED;
ERR;
STOP;
}
work_mode = enum {
UNICAST;
BROADCAST;
SMALLCLASS;
}
#log interfaces for special platform
i_log = interface +c +o +j {
warn(tag: string, message: string);
debug(tag: string, message: string);
error(tag: string, message: string);
info(tag: string, message: string);
verbose(tag: string, message: string);
sc(tag: string, message: string);
sc1(tag: string);
}
#async task class
i_async_task = interface +c {
execute();
}
#run loop class for special platform to implement and pass to native
i_event_loop = interface +c +o +j {
post(task: i_async_task);
}
i_api_observer = interface +c +o +j {
onClassroomState(state: string,errorCode: i32, msg: string);
onCoreInitState(state: string);
onCameraCtrlResponse(resp: string);
onMicCtrlResponse(rest: string);
onSpeakerCtrlResponse(resp: string);
onException(msg:string);
}
i_video_observer = interface +c +o +j {
onRemoteVideoFrame(uid: string, video_frame: i_video_frame);
onPriviewVideoFrame(uid: string, video_frame: i_video_frame);
onPreProcessPriviewVideoFrame(uid: string, video_frame: i_video_frame): i_video_frame; //返回一个i_video_frame类型
}
#why need to export class coreSdk?
coreSdk = interface +c {
onCreate(vendor:sdk_vendor,option: string);
onStart(config: string);
onSendVideoFrame(type: i32, videoFrame: i_video_frame);
onSendAudioFrame(audioFrame: i_audio_frame);
onSendAppData(AppData: string);
onNetworkChange(networkStatus: string);
onAppstatusChange(appStatus: string);
onSetClassInformation(config: string);
onCameraCtrl(config: string);
onMicCtrl(config: string);
onSpeakerCtrl(config: string);
onRoomCtrl(config: string);
onStop();
onRelease();
}
#rtc api class for app layer to invoke with
rtcApi = interface +c {
static creatertcApi(log: i_log, ui_thread: i_event_loop): chinookApi;
static getVersion(): string;
setApiObserver(apiObserver: i_api_observer);
setNetworkObserver(netObserver: i_network_observer);
setVideoObserver(videoObserver: i_video_observer);
setAudioObserver(audioObserver: i_audio_observer);
setAppObserver(appObserver: i_app_observer);
setNetworkStatus(networkStatus: string);
setAppStatus(appStatus: string);
InitCoreSdk(type: sdk_vendor, option: string);
ReleaseCore(type: sdk_vendor);
sendVideoFrame(source_width: i32, source_height: i32, type: i32, videoFrame: i_video_frame);
sendAudioFrame(audioFrame: i_audio_frame);
sendAppData(AppData: string): string;
setClassInformation(config: string);
cameraCtrl(config: string);
micCtrl(config: string);
speakerCtrl(config: string);
roomCtrl(config: string);
enterClassroom(config: string);
exitClassroom();
test(config:string);
}