KalayFlutter(简中版)

KalayFlutter(AVAPI)


Flutter API

<p>[TOC]</p> <p>&lt;a id=&quot;1.1&quot;&gt;&lt;/a&gt;</p> <h2>1.1 Init/Uninit</h2> <p>&lt;a id=&quot;1.1.1&quot;&gt;&lt;/a&gt;</p> <h3>1.1.1 TF_initWithSDK</h3> <pre><code>/// IOTC初始化 /// - Parameters: ///   - liceseKey: licenseKey SDK初始化的Key值 ///   - privateKey: privateKey PSC初始化的Key值(有效期内使用才有效) fileprivate func TF_initWithSDK(_ liceseKey: String, _ privateKey: String)</code></pre> <pre><code>Flutter示例: _methodChannel.invokeMethod('TF_initWithSDK',{'privateKey': privateKey, 'licenseKey': licenseKey});</code></pre> <hr /> <p>&lt;a id=&quot;1.1.2&quot;&gt;&lt;/a&gt;</p> <h3>1.1.2 TF_uninitIOTC</h3> <pre><code>///  IOTC反初始化 fileprivate func TF_uninitIOTC()</code></pre> <pre><code>Flutter示例: _methodChannel.invokeMethod('TF_uninitIOTC');</code></pre> <hr /> <p>&lt;a id=&quot;1.1.3&quot;&gt;&lt;/a&gt;</p> <h3>1.1.3 TF_getSDKVersion</h3> <pre><code>/// 获取SDK版本号 fileprivate func TF_getSDKVersion()</code></pre> <pre><code>Flutter示例: _methodChannel.invokeMethod('TF_getSDKVersion');</code></pre> <hr /> <p>&lt;a id=&quot;1.1.4&quot;&gt;&lt;/a&gt;</p> <h3>1.1.4 TF_setLog</h3> <pre><code>/// 设置日志 /// - Parameters: ///   - enbal: 是否开启记录 ///   - level: 日志等级 fileprivate func TF_setLog(enbal: Bool, level: UInt32 = 0)</code></pre> <pre><code>Flutter示例: _methodChannel.invokeMethod('TF_setLog');</code></pre> <hr /> <p>&lt;a id=&quot;1.2&quot;&gt;&lt;/a&gt;</p> <h2>1.2 Video/Audio</h2> <p>&lt;a id=&quot;1.2.1&quot;&gt;&lt;/a&gt;</p> <h3>1.2.1 TF_connect</h3> <pre><code>/// 连线设备及出图 /// - Parameters: ///   - uid: 设备UID ///   - authkey: 连线验证的authkey fileprivate func TF_connect(uid: String, authkey: String?)</code></pre> <pre><code>Flutter示例: _methodChannel.invokeMethod('TF_connect');</code></pre> <hr /> <p>&lt;a id=&quot;1.2.2&quot;&gt;&lt;/a&gt;</p> <h3>1.2.2 TF_startChannel</h3> <pre><code>/// 开启AV通道 /// - Parameters: ///   - channel: av通道号 ///   - password: 设备密码 fileprivate func TF_startChannel(channel: Int = 0, password: String)</code></pre> <pre><code>Flutter示例: _methodChannel.invokeMethod('TF_startChannel',{password: password});</code></pre> <hr /> <p>&lt;a id=&quot;1.2.3&quot;&gt;&lt;/a&gt;</p> <h3>1.2.3 TF_stopChannel</h3> <pre><code>///  关闭AV通道 /// - Parameter channel: av通道号 fileprivate func TF_stopChannel(channel: Int = 0)</code></pre> <pre><code>Flutter示例: _methodChannel.invokeMethod('TF_stopChannel');</code></pre> <hr /> <p>&lt;a id=&quot;1.2.4&quot;&gt;&lt;/a&gt;</p> <h3>1.2.4 TF_sethwDecode</h3> <pre><code>/// 设置指定通道的解码方式 /// - Parameters: ///   - channel: channel av通道 ///   - isHWDecode: 是否硬解码 fileprivate func TF_sethwDecode(channel: Int = 0 , isHWDecode: Bool)</code></pre> <pre><code>Flutter示例: _methodChannel.invokeMethod('TF_sethwDecode');</code></pre> <hr /> <p>&lt;a id=&quot;1.2.5&quot;&gt;&lt;/a&gt;</p> <h3>1.2.5 TF_startDevice</h3> <pre><code>/// 开始对讲(发送声音到设备) /// - Parameter channel: av通道 fileprivate func TF_startDevice(channel: Int = 0)</code></pre> <pre><code>Flutter示例: _methodChannel.invokeMethod('TF_startDevice');</code></pre> <hr /> <p>&lt;a id=&quot;1.2.6&quot;&gt;&lt;/a&gt;</p> <h3>1.2.6 TF_stopDevice</h3> <pre><code>/// 停止对讲 /// - Parameter channel: av通道 fileprivate func TF_stopDevice(channel: Int = 0)</code></pre> <pre><code>Flutter示例: _methodChannel.invokeMethod('TF_stopDevice');</code></pre> <hr /> <p>&lt;a id=&quot;1.2.7&quot;&gt;&lt;/a&gt;</p> <h3>1.2.7 TF_startPhone</h3> <pre><code>/// 开始接收、解码并监听设备声音 /// - Parameter channel: av通道 fileprivate func TF_startPhone(channel: Int = 0)</code></pre> <pre><code>Flutter示例: _methodChannel.invokeMethod('TF_startPhone');</code></pre> <hr /> <p>&lt;a id=&quot;1.2.8&quot;&gt;&lt;/a&gt;</p> <h3>1.2.8 TF_stopPhone</h3> <pre><code>/// 停止接收、解码和监听设备声音 /// - Parameter channel: av通道 fileprivate func TF_stopPhone(channel: Int = 0)</code></pre> <pre><code>Flutter示例: _methodChannel.invokeMethod('TF_stopPhone');</code></pre> <hr /> <p>&lt;a id=&quot;1.2.9&quot;&gt;&lt;/a&gt;</p> <h3>1.2.9 TF_startShow</h3> <pre><code>/// 开始视频接收、解码并播放 /// - Parameter channel: av通道 fileprivate func TF_startShow(channel: Int = 0)</code></pre> <pre><code>Flutter示例: _methodChannel.invokeMethod('TF_startShow');</code></pre> <hr /> <p>&lt;a id=&quot;1.2.10&quot;&gt;&lt;/a&gt;</p> <h3>1.2.10 TF_stopShow</h3> <pre><code>/// 停止接收、解码和画面显示 /// - Parameter channel: av通道 fileprivate func TF_stopShow(channel: Int = 0)</code></pre> <pre><code>Flutter示例: _methodChannel.invokeMethod('TF_stopShow');</code></pre> <hr /> <p>&lt;a id=&quot;1.2.11&quot;&gt;&lt;/a&gt;</p> <h3>1.2.11 TF_disconnect</h3> <pre><code>/// 断开连线设备 fileprivate func TF_disconnect()</code></pre> <pre><code>Flutter示例: _methodChannel.invokeMethod('TF_disconnect');</code></pre> <hr /> <p>&lt;a id=&quot;1.3&quot;&gt;&lt;/a&gt;</p> <h2>1.3 Recording/Snapshot</h2> <p>&lt;a id=&quot;1.3.1&quot;&gt;&lt;/a&gt;</p> <h3>1.3.1 TF_startRecord</h3> <pre><code>/// 指定通道并开始录像 /// - Parameters: ///   - path: 沙盒路径 ///   - channel: av通道 fileprivate func TF_startRecord(_ path: String, channel: Int = 0)</code></pre> <pre><code>Flutter示例: _methodChannel.invokeMethod('TF_startRecord', {'filePath': recordfilePath});</code></pre> <hr /> <p>&lt;a id=&quot;1.3.2&quot;&gt;&lt;/a&gt;</p> <h3>1.3.2 TF_stopRecord</h3> <pre><code>/// 停止录像 /// - Parameter channel: av通道 fileprivate func TF_stopRecord(channel: Int = 0)</code></pre> <pre><code>Flutter示例: _methodChannel.invokeMethod('TF_stopRecord');</code></pre> <hr /> <p>&lt;a id=&quot;1.3.3&quot;&gt;&lt;/a&gt;</p> <h3>1.3.3 TF_savePhoto</h3> <pre><code>/// 保存系统相册 fileprivate func TF_savePhoto()</code></pre> <pre><code>Flutter示例: _methodChannel.invokeMethod('TF_savePhoto');</code></pre> <hr /> <p>&lt;a id=&quot;1.4&quot;&gt;&lt;/a&gt;</p> <h2>1.4 Send Command</h2> <p>&lt;a id=&quot;1.4.1&quot;&gt;&lt;/a&gt;</p> <h3>1.4.1 TF_sendCommand</h3> <pre><code>指令建议写在原生页面 /// 指令发送 /// - Parameter type: 指令类型 fileprivate func TF_sendCommand(type: Int) { switch type { case TKFlutterCameraCommandType.getAudioFormat.rawValue: self.commandGetAudioFormat() break case TKFlutterCameraCommandType.getDeviceInfo.rawValue: self.commandDeviceInfo() break default: break } }</code></pre> <pre><code>Flutter示例: _methodChannel.invokeMethod('TF_sendCommand', {'type': 0x032A});</code></pre> <hr /> <p>&lt;a id=&quot;1.5&quot;&gt;&lt;/a&gt;</p> <h2>1.5 Delegate</h2> <p>&lt;a id=&quot;1.5.1&quot;&gt;&lt;/a&gt;</p> <h3>1.5.1 TF_getSDKVersionCallback</h3> <pre><code>Flutter示例: DispatchQueue.main.async { [self] in methodChannel?.invokeMethod(TKFlutterCameraLiveCallbackInvokeMethod.getSDKVersionCallback.rawValue, arguments: [&amp;quot;version&amp;quot;: version]) }</code></pre> <hr /> <p>&lt;a id=&quot;1.5.2&quot;&gt;&lt;/a&gt;</p> <h3>1.5.2 TF_sessionStatusCallback</h3> <pre><code>/**  连线状态回调  @param camera camera对象  @param status session连线结果 0 成功 other 失败  @param errorCode TK_connect连线返回结果 &amp;gt;=0 成功 , other 失败  */ public func camera(_ camera: Camera, didChangeSessionStatus status: Int, errorCode: Int) { // 版本升级,invokeMethod必须再主线程进行发送 DispatchQueue.main.async { [self] in methodChannel?.invokeMethod(TKFlutterCameraLiveCallbackInvokeMethod.sessionStatusCallback.rawValue, arguments: [&amp;quot;status&amp;quot;: String(format: &amp;quot;%d&amp;quot;, status)]) } }</code></pre> <hr /> <p>&lt;a id=&quot;1.5.3&quot;&gt;&lt;/a&gt;</p> <h3>1.5.3 TF_channelStatusCallback</h3> <pre><code>/**  指定通道的连线状态回调  @param camera camera对象  @param channel av通道  @param status 连线状态  @param errorCode TK_start av通道返回结果 0 成功 , other 失败  */ public func camera(\_ camera: Camera, didChangeChannelStatus channel: Int, channelStatus status: Int, errorCode: Int) {         DispatchQueue.main.async { [self] in             methodChannel?.invokeMethod(TKFlutterCameraLiveCallbackInvokeMethod.channelStatusCallback.rawValue, arguments: \[&amp;quot;status&amp;quot;: String(format: &amp;quot;%d&amp;quot;, status), &amp;quot;channel&amp;quot;: String(format: &amp;quot;%d&amp;quot;, channel)\])         }     }</code></pre> <hr /> <pre><code>enum status: Int { case _NONE = 0 //初始化连线状态 case _CONNECTING = 1 //设备连线中 未返回状态 case _CONNECTED = 2 //设备已连线 返回状态&amp;gt;= 0 case _DISCONNECTED = 3 //设备未连线 返回状态 -22 AV其它 case _UNKNOWN_DEVICE = 4 //未知设备 返回状态 -15 case _WRONG_PASSWORD = 5 //设备连线密码错误 返回状态 -20009 case _TIMEOUT = 6 //设备连线超时 返回状态-13 -23 -20016 -20011 case _UNSUPPORTED = 7 //不支持设备 返回状态-40 case _CONNECT_FAILED = 8 //设备连线失败 其它 case _UNKNOWN_LICENSE = 9 //设备uid未在license中 返回状态 -10 case _SLEEP = 10 //设备睡眠状态 返回状态 -64 case _DEVICE_MAX_SESSION = 11 //超过设备最大连线数 返回状态-48 case _POOR_NETWORKSIGNAL = 12 //网络信号差 返回状态 -19 -42 case _WRONG_AUTHKEY = 13 //authkey不正确 返回状态 -46 -68 }</code></pre> <p>&lt;a id=&quot;1.5.4&quot;&gt;&lt;/a&gt;</p> <h3>1.5.4 TF_recordStartCallback</h3> <pre><code>DispatchQueue.main.async { [self] in methodChannel?.invokeMethod(TKFlutterCameraLiveCallbackInvokeMethod.recordStartCallback.rawValue, arguments: [&amp;quot;status&amp;quot;: true]) }</code></pre> <hr /> <p>&lt;a id=&quot;1.5.5&quot;&gt;&lt;/a&gt;</p> <h3>1.5.5 TF_recordSuccessCallback</h3> <pre><code>DispatchQueue.main.async { [self] in methodChannel?.invokeMethod(TKFlutterCameraLiveCallbackInvokeMethod.recordSuccessCallback.rawValue, arguments: [&amp;quot;result&amp;quot;: result]) }</code></pre> <hr /> <p>&lt;a id=&quot;1.5.6&quot;&gt;&lt;/a&gt;</p> <h3>1.5.6 TF_recordTimeCallback</h3> <pre><code>DispatchQueue.main.async { [self] in methodChannel?.invokeMethod(TKFlutterCameraLiveCallbackInvokeMethod.recordTimeCallback.rawValue, arguments: [&amp;quot;time&amp;quot;: recordTimeCount]) }</code></pre> <hr /> <p>&lt;a id=&quot;1.5.7&quot;&gt;&lt;/a&gt;</p> <h3>1.5.7 TF_photoSuccessCallback</h3> <pre><code>DispatchQueue.main.async { self.methodChannel?.invokeMethod(TKFlutterCameraLiveCallbackInvokeMethod.photoSuccessCallback.rawValue, arguments: [&amp;quot;result&amp;quot;: isSuccess]) }</code></pre> <hr /> <p>&lt;a id=&quot;1.5.8&quot;&gt;&lt;/a&gt;</p> <h3>1.5.8 TF_cameraDebugInfoCallback</h3> <pre><code>/**  指定通道的视频宽高/fps/bps/在线人数/帧数/丢帧数等调试信息回调  @param camera camera对象  @param channel av通道  @param videoWidth 视频宽  @param videoHeight 视频高  @param fps fps  @param videoBps 视频bps  @param audioBps 音频bps  @param onlineNm 在线人数  @param frameCount 帧数  @param incompleteFrameCount 丢帧数  @param isHwDecode 是否是硬解  */ public func camera(_ camera: Camera, didReceiveFrameInfoWithChannel channel: Int, videoWidth: Int, videoHeight: Int, videoFPS fps: Int, videoBPS videoBps: Int, audioBPS audioBps: Int, onlineNm: Int, frameCount: UInt, incompleteFrameCount: UInt, isHwDecode: Bool) {         let cameraInfo = String(format: &amp;quot;%ld×%ld %@ \n%@:%u/%u, fps:%ld \nvideoBps: %ldKbps\naudioBps: %ldKbps\n%@:%ld SID:%ld\navIndex:%u CMD:%u,%u&amp;quot;, videoWidth, videoHeight, getConnModeString(camera.sessionMode), &amp;quot;Rcv&amp;quot;, incompleteFrameCount, frameCount, fps, videoBps / 1024, audioBps / 1024, &amp;quot;Viewers&amp;quot;, onlineNm, camera.sessionID, camera.avChannelIndex, camera.cmdNum, camera.cmdReturn)         DispatchQueue.main.async { [self] in             methodChannel?.invokeMethod(TKFlutterCameraLiveCallbackInvokeMethod.cameraDebugInfoCallback.rawValue, arguments: [&amp;quot;info&amp;quot;: cameraInfo]) } }</code></pre> <hr /> <p>&lt;a id=&quot;1.6&quot;&gt;&lt;/a&gt;</p> <h2>1.6 Others</h2> <p>&lt;a id=&quot;1.6.1&quot;&gt;&lt;/a&gt;</p> <h3>1.6.1 FRAMEINFO_t</h3> <pre><code>/** Audio/Video Frame Header Info */ typedef struct _FRAMEINFO{ unsigned short codec_id; // defined in ENUM_CODECID, unsigned char flags; // Combined with IPC_FRAME_xxx. unsigned char cam_index; // 0 - n unsigned char onlineNum; // number of client connected this device unsigned char reserve1[3]; unsigned int reserve2; // unsigned int timestamp; // Timestamp of the frame, in milliseconds }FRAMEINFO_t;</code></pre> <hr /> <p>&lt;a id=&quot;1.6.2&quot;&gt;&lt;/a&gt;</p> <h3>1.6.2 ENUM_CODECID</h3> <pre><code>/** CODEC ID */ typedef NS_ENUM(NSInteger, ENUM_CODECID) { MEDIA_CODEC_UNKNOWN = 0x00, MEDIA_CODEC_VIDEO_MPEG4 = 0x4C, MEDIA_CODEC_VIDEO_H263 = 0x4D, MEDIA_CODEC_VIDEO_H264 = 0x4E, MEDIA_CODEC_VIDEO_MJPEG = 0x4F, MEDIA_CODEC_VIDEO_H265 = 0x50, MEDIA_CODEC_AUDIO_AAC_RAW = 0x86, MEDIA_CODEC_AUDIO_AAC_ADTS = 0x87, MEDIA_CODEC_AUDIO_AAC_LATM = 0x88, // 2014-07-02 add AAC audio codec definition MEDIA_CODEC_AUDIO_G711U = 0x89, //g711 u-law MEDIA_CODEC_AUDIO_G711A = 0x8A, //g711 a-law MEDIA_CODEC_AUDIO_ADPCM = 0X8B, MEDIA_CODEC_AUDIO_PCM = 0x8C, MEDIA_CODEC_AUDIO_SPEEX = 0x8D, MEDIA_CODEC_AUDIO_MP3 = 0x8E, MEDIA_CODEC_AUDIO_G726 = 0x8F, };</code></pre> <hr />

页面列表

ITEM_HTML