Kalay1.0标准-升级版PSC

Kalay1.0 升级版PSC


Android API

<p>[TOC]</p> <h1>一、IOTCamera</h1> <h2>1.1 Initialization interface, static API</h2> <h3>TK_initIOTC</h3> <pre><code class="language-java">/** * IOTC initialize * &amp;lt;p&amp;gt; * Error: * -1004 sdkLicenseKey invalid * -10000 privateKey invalid * -10003 privateKey expired * * @param context context * @param privateKey Initialization privateKey value * @param sdkLicenseKey Initialization licenseKey value * @param listener response block of initialization */ public synchronized static void TK_initIOTC(Context context, String privateKey, String sdkLicenseKey, TK_Listener listener);</code></pre> <pre><code class="language-java">TK_Listener#Response Object description public class Response { /** * 1、When accessing privateKey check service Domain fails, return http response string * 2、When the access is successful, return the msg field in the response string * 3、When P2P initialization fails, P2P failure msg is returned. */ @Nullable public String msg; /** * privateKey checks the actual IP of the service Domain */ @Nullable public String ip; /** * 1、When accessing privateKey check service Domain fails, return http error code * 2、When the access is successful, return the msg field in the response string,ex:-10000(privateKey invalid)、10001(privateKey forever)、10002(privateKey in used)、-10003(privateKey expired)、 * 3、When P2P initialization fails, P2P failure msg is returned,ex:-1004(sdkkey invalid)、-1005(sdkkey invalid)、-3(initialize repeated)、-20031(initialize repeated)、-40032(initialize repeated) */ public int code; @Override public String toString() { return &amp;quot;code = &amp;quot; + code + &amp;quot;, ip = &amp;quot; + ip + &amp;quot;, msg = &amp;quot; + msg; } }</code></pre> <pre><code class="language-java">Example: Camera.TK_initIOTC(context, privateKey, sdkLicensekey, new TK_Listener() { @Override public void success(Response response) { //success } @Override public void failure(Response response) { //error } @Override public void doInBackground() { } });</code></pre> <pre><code>comment:If the Android SDK used by the app is greater than 27 (that is, using SDK 9.0 or above), you need to add parameters in the application of AndroidManifest.xml android:usesCleartextTraffic=&amp;quot;true&amp;quot; Otherwise, the initialization will be unsuccessful.; Example: &amp;lt;application android:icon=&amp;quot;@mipmap/ic_launcher&amp;quot; android:label=&amp;quot;@string/app_name&amp;quot; android:roundIcon=&amp;quot;@mipmap/ic_launcher&amp;quot; android:usesCleartextTraffic=&amp;quot;true&amp;quot; android:theme=&amp;quot;@style/AppTheme&amp;quot;&amp;gt; &amp;lt;/application&amp;gt;</code></pre> <p>&gt; Comment:-10000 is returned when calling TK_initIOTC because the privateKey is invalid. It is recommended when encountering this problem.:</p> <ul> <li>Confirm whether the package name and privateKey used by the current project are consistent with those provided by TUTK. If they are inconsistent, please modify the package name and privateKey provided by TUTK and run again.;</li> <li>If you need to change the package name and privateKey, please contact business or technical support personnel。</li> </ul> <h3>TK_unInitIOTC</h3> <pre><code class="language-java">/** * IOTC deinitialization */ public synchronized static int TK_unInitIOTC();</code></pre> <pre><code class="language-java">Example: Camera.TK_unInitIOTC();</code></pre> <h3>TK_setMasterRegion</h3> <pre><code class="language-java">/** * P2P partition distribution * &amp;lt;p&amp;gt; * Need to be called before {@link #TK_initIOTC} * * @param region 0: All; 1: Greater China; 2: Europe; 3: Americas. */ public static void TK_setMasterRegion(int region);</code></pre> <pre><code class="language-java">Example: Camera.TK_setMasterRegion(1);</code></pre> <h3>TK_getIOTCameraVersion</h3> <pre><code class="language-java">/** * Get IOTCamera version number */ public static String TK_getIOTCameraVersion();</code></pre> <pre><code class="language-java">Example: Camera.TK_getIOTCameraVersion();</code></pre> <h3>TK_getIOTCAPIsVerion</h3> <pre><code class="language-java">/** * Returns the version of IOTCAPI */ public static String TK_getIOTCAPIsVerion();</code></pre> <pre><code class="language-java">Example: Camera.TK_getIOTCAPIsVerion();</code></pre> <h3>TK_getAVAPIsVersion</h3> <pre><code class="language-java">/** * Returns the version of AVAPIs */ public static String TK_getAVAPIsVersion();</code></pre> <pre><code class="language-java">Example: Camera.TK_getAVAPIsVersion();</code></pre> <h3>TK_LanSearch</h3> <pre><code class="language-java">/** * search location devices * * @param timeoutMs timeout of search * @return Device information searched under the local network */ public static st_LanSearchInfo[] TK_LanSearch(int timeoutMs);</code></pre> <pre><code class="language-java">Example: st_LanSearchInfo[] arrResp = Camera.TK_LanSearch(2000); if (arrResp != null) { for (st_LanSearchInfo info : arrResp) { Log.i(TAG, &amp;quot;uid: &amp;quot; + new String(info.UID) + &amp;quot; ip:&amp;quot; + new String(info.IP)); } }</code></pre> <h3>TK_setLogEnable</h3> <pre><code class="language-java">/** * Set log records * * @param enable whether open log records or not * @param path After setting the path, the log sandbox storage path is * &amp;lt;path&amp;gt;/yyyy-MM-dd/HH:mm:ss/Console.txt * &amp;lt;path&amp;gt;/yyyy-MM-dd/HH:mm:ss/IOTC.txt * &amp;lt;path&amp;gt;/yyyy-MM-dd/HH:mm:ss/AVAPI.txt * &amp;lt;path&amp;gt;/yyyy-MM-dd/HH:mm:ss/RDT.txt * &amp;lt;path&amp;gt;/yyyy-MM-dd/HH:mm:ss/Global.txt * @param level log level */ public static void TK_setLogEnable(boolean enable, String path, LogLevel level); </code></pre> <h2>1.2 callback interface</h2> <h3>1.2.1 P2P callback interface</h3> <h4>TK_registerIOTCListener</h4> <pre><code class="language-java">/** * Register IOTC callback */ public boolean TK_registerIOTCListener(InterfaceCtrl.IOTCListener listener); /** * Unregister IOTC callback */ public boolean TK_unregisterIOTCListener(InterfaceCtrl.IOTCListener listener);</code></pre> <pre><code class="language-java">public interface IOTCListener { /** * nebula binding information callback * &amp;lt;p&amp;gt; * When {@link com.tutk.IOTC.Camera#TK_nebulaBind} is called, the connection result is called back * * @param camera * @param credential Binding result, null when binding fails * @param resultCode resultCode Binding results * @param p2pCode p2p return value */ void receiveBindInfo(Camera camera, String credential, int resultCode, int p2pCode); /** * IOTC connection information callback * &amp;lt;p&amp;gt; * 1、When {@link com.tutk.IOTC.Camera#TK_connect} is called, the connection result is called back * 2、When {@link com.tutk.IOTC.Camera#TK_nebulaConnect} is called, the connection result is called back * * @param camera * @param resultCode Connection results * @param p2pCode p2p callback result code */ void receiveSessionInfo(Camera camera, int resultCode, int p2pCode); /** * AV channel connection information callback * &amp;lt;p&amp;gt; * When {@link com.tutk.IOTC.Camera#TK_start} is called, the connection result is called back * * @param camera * @param avChannel av channel * @param resultCode Connection results * @param p2pCode p2p callback result code */ void receiveChannelInfo(Camera camera, int avChannel, int resultCode, int p2pCode); /** * Receive Command information callback * &amp;lt;p&amp;gt; * After the connection is successful, when the command is received from the device, the command data is called back * * @param camera * @param avChannel av channel * @param avIOCtrlMsgType Type of information received * @param data information received */ void receiveIOCtrlData(Camera camera, int avChannel, int avIOCtrlMsgType, byte[] data); /** * Callback whether intercom is successful * &amp;lt;p&amp;gt; * When calling {@link com.tutk.IOTC.Camera#TK_startSoundToDevice}, callback whether the intercom is successful * * @param camera * @param avChannel av channel * @param success Whether the intercom is successful */ void receiveSoundToDevice(Camera camera, int avChannel, boolean success); /** * Monitor whether callback is successful * &amp;lt;p&amp;gt; * When calling {@link com.tutk.IOTC.Camera#TK_startSoundToPhone}, whether the callback is successfully monitored * * @param camera * @param avChannel av channel * @param success Whether monitoring is successful */ void receiveSoundToPhone(Camera camera, int avChannel, boolean success); /** * Send Command debugging information callback * &amp;lt;p&amp;gt; * After the connection is successful, when {@link com.tutk.IOTC.Camera#TK_sendIOCtrlToChannel} is called to send instructions to the device, the callback sends the result. * * @param camera * @param avChannel av channel * @param avIOCtrlMsgType Type of message sent * @param p2pCode sent p2p return value * @param data Send message data */ void sendIOCtrlData(Camera camera, int avChannel, int avIOCtrlMsgType, int p2pCode, byte[] data); /** * Send Command debugging information callback * &amp;lt;p&amp;gt; * 1、After the connection is successful, when {@link com.tutk.IOTC.Camera#TK_sendJsonCtrlToChannel} is called to send instructions to the device, the callback sends the result. * 2、After the connection is successful, when {@link com.tutk.IOTC.Camera#TK_nebulaSendData} is called to send instructions to the device, the callback sends the result. * * @param camera * @param avChannel av channel * @param jsonRequest json data sent * @param jsonResponse What the device returns * @param p2pCode sent p2p return value */ void sendJsonCtrlData(Camera camera, int avChannel, String jsonRequest, String jsonResponse, int p2pCode); /** * File upload and download callbacks * &amp;lt;p&amp;gt; * 1、After the connection is successful, when calling {@link com.tutk.IOTC.Camera#TK_startDownload} to start file download, the download progress will be called back. * 2、After the connection is successful, when {@link com.tutk.IOTC.Camera#TK_startUpload} is called to start file upload, the upload progress is called back. * * @param camera * @param channel channel number * @param filePath File full sandbox path * @param progress Upload/download progress * @param loadType Download or upload type (AVIOCTRLDEFs.FILETransferType_Download/AVIOCTRLDEFs.FILETransferType_Upload) * @param p2pCode p2p result code */ void downloadUploadOutput(Camera camera, int channel, String filePath, int progress, int loadType, int p2pCode); }</code></pre> <pre><code class="language-java">Example: Camera camera = new Camera(); camera.TK_registerIOTCListener(new SimpleIOTCListener());</code></pre> <table> <thead> <tr> <th>resultCode Connection results</th> <th>definition</th> </tr> </thead> <tbody> <tr> <td>CONNECTION_STATE_CONNECTING = 1</td> <td>connecting</td> </tr> <tr> <td>CONNECTION_STATE_CONNECTED = 2</td> <td>connect success</td> </tr> <tr> <td>CONNECTION_STATE_DISCONNECTED = 3</td> <td>disconnect</td> </tr> <tr> <td>CONNECTION_STATE_UNKNOWN_DEVICE = 4</td> <td>unkown device</td> </tr> <tr> <td>CONNECTION_STATE_WRONG_PASSWORD = 5</td> <td>wrong password</td> </tr> <tr> <td>CONNECTION_STATE_TIMEOUT = 6</td> <td>connect timeout</td> </tr> <tr> <td>CONNECTION_STATE_UNSUPPORTED = 7</td> <td>device unsupport connect</td> </tr> <tr> <td>CONNECTION_STATE_CONNECT_FAILED = 8</td> <td>connect fail</td> </tr> <tr> <td>CONNECTION_STATE_UNKNOWN_LICENSE = 9</td> <td>device uid not in license</td> </tr> <tr> <td>CONNECTION_STATE_SLEEP = 10</td> <td>device sleep state</td> </tr> <tr> <td>CONNECTION_STATE_DEVICE_MAX_SESSION = 11</td> <td>Exceeded the maximum number of connections to the device</td> </tr> <tr> <td>CONNECTION_STATE_POOR_NETWORKSIGNA = 12</td> <td>Poor network signal</td> </tr> <tr> <td>CONNECTION_STATE_WRONG_AUTH_KEY = 13</td> <td>wrong authKey</td> </tr> <tr> <td>CONNECTION_STATE_SELF_DISCONNECT = 14</td> <td>The App actively disconnects during the connection process.</td> </tr> </tbody> </table> <h3>1.2.2 Audio and video callback interface</h3> <h4>TK_registerMediaDataListener</h4> <pre><code class="language-java">/** * Register audio and video data callback */ public boolean TK_registerMediaDataListener(InterfaceCtrl.MediaDataListener listener); /** * Logout audio and video data callback */ public boolean TK_unregisterMediaDataListener(InterfaceCtrl.MediaDataListener listener);</code></pre> <pre><code class="language-java">public interface MediaDataListener { /** * Video decoding data callback * &amp;lt;p&amp;gt; * When {@link com.tutk.IOTC.Camera#TK_startShow} is called, the video decoding information is called back * * @param avFrame Decode current frame * @param isSoftwareDecode whether is software decode or not * @param decodeAfter decoded data,yuv/rgb/null * @param videoWidth video width * @param videoHeight video height */ void onDecodeVideoData(Camera camera, int avChannel, AVFrame avFrame, byte[] decodeAfter, int videoWidth, int videoHeight, boolean isSoftwareDecode); /** * Video receiving raw data callback * &amp;lt;p&amp;gt; * When {@link com.tutk.IOTC.Camera#TK_startShow} is called, the callback video receives information * * @param avFrame receive current frame */ void onRecvVideoFrame(Camera camera, int avChannel, AVFrame avFrame); /** * Video debugging information callback * &amp;lt;p&amp;gt; * When {@link com.tutk.IOTC.Camera#TK_startShow} is called, debugging information is called back * * @param bitRate Audio and video bitrate within 1 second (bps) * @param frameRate Video decoding frame rate within 1s (fps) * @param onlineNm online num * @param frameCount Total number of video frames received * @param incompleteFrameCount Total number of video frames dropped */ void onRecvVideoInfo(Camera camera, int avChannel, long bitRate, int frameRate, int onlineNm, int frameCount, int incompleteFrameCount); /** * Audio decoding data callback * &amp;lt;p&amp;gt; * When calling {@link com.tutk.IOTC.Camera#TK_startSoundToPhone}, callback decoding information * * @param avFrame decode current frame * @param decodeAfter Decoded PCM data */ void onDecodeAudioData(Camera camera, int avChannel, AVFrame avFrame, byte[] decodeAfter); /** * Audio receiving raw data callback * &amp;lt;p&amp;gt; * When {@link com.tutk.IOTC.Camera#TK_startSoundToPhone} is called, callback audio reception information * * @param avChannel av channel , Generally 0 * @param avFrame receive current frame */ void onRecvAudioFrame(Camera camera, int avChannel, AVFrame avFrame); /** * Audio collection raw data callback * &amp;lt;p&amp;gt; * When {@link com.tutk.IOTC.Camera#TK_startSoundToDevice} is called, the audio collection information is called back * * @param avChannel av channel , Generally 0 * @param avFrame send current frame */ void onSendAudioFrame(Camera camera, int avChannel, AVFrame avFrame); }</code></pre> <pre><code class="language-java">Example: Camera camera = new Camera(); camera.TK_registerIOTCListener(new SimpleMediaDataListener());</code></pre> <h2>1.3 connection processing</h2> <h3>1.3.1 P2P</h3> <h4>TK_connect</h4> <pre><code class="language-java">/** * connect Device * &amp;lt;p&amp;gt; * The connection result is obtained using {@link #TK_registerIOTCListener} * * @param uid 20-digit uid serial number * @see InterfaceCtrl.IOTCListener#receiveSessionInfo */ public abstract void TK_connect(String uid); /** * connect Device * &amp;lt;p&amp;gt; * The connection result is obtained using {@link #TK_registerIOTCListener} * * @param uid 20-digit uid serial number * @param authKey authKey for online authentication * @see InterfaceCtrl.IOTCListener#receiveSessionInfo */ public abstract void TK_connect(String uid, String authKey);</code></pre> <pre><code class="language-java">Example: Camera camera = new Camera(); camera.TK_connect(uid, authKey); camera.TK_registerIOTCListener(new InterfaceCtrl.SimpleIOTCListener() { @Override public void receiveSessionInfo(Camera camera, int resultCode) { if (resultCode == Camera.CONNECTION_STATE_CONNECTED) { //connect success } } });</code></pre> <h3>1.3.2 Nebula</h3> <h4>TK_nebulaStartBind</h4> <pre><code class="language-java">/** * Nebula start binding device * &amp;lt;p&amp;gt; * Use {@link #TK_registerIOTCListener} to get the binding result * * @param udid 40-digit uid serial number * @param bindType bind type PIN_CODE(0), CREDENTIAL(1), AP(2); * @param bindKey Relevant to the binding method, the filled in values are pin code, credential, password * @see InterfaceCtrl.IOTCListener#receiveBindInfo */ void TK_nebulaStartBind(String udid, Camera.BindType bindType, String bindKey);</code></pre> <pre><code class="language-java">Example: camera.TK_nebulaStartBind(udid, Camera.BindType.PIN_CODE, &amp;quot;123456&amp;quot;); camera.TK_registerIOTCListener(new InterfaceCtrl.SimpleIOTCListener(){ @Override public void receiveBindInfo(Camera camera, String credential, int resultCode, int p2pCode) { if(resultCode == Camera.CONNECTION_STATE_CONNECTED){ //nebula bind success } } });</code></pre> <h4>TK_nebulaStopBind</h4> <pre><code class="language-java">/** * Nebula Stop binding device */ void TK_nebulaStopBind();</code></pre> <h4>TK_nebulaConnect</h4> <pre><code class="language-java">/** * Nebula connect device * &amp;lt;p&amp;gt; * Use {@link #TK_registerIOTCListener} to get the connection result * * @param udid 40-digit uid serial number * @param credential Credential generated after device binding * @param avToken The token required for connection is provided by am server * @param realm Need to be consistent with the device * @see InterfaceCtrl.IOTCListener#receiveSessionInfo */ void TK_nebulaConnect(String udid, String credential, String avToken, String realm); /** * Nebula Connected devices * &amp;lt;p&amp;gt; * Use {@link #TK_registerIOTCListener} to get the connection result * * @param udid 40-digit uid serial number * @param credential Credential generated after device binding * @param avToken The token required for connection is provided by am server * @param realm Need to be consistent with the device * @param isWakeup whether wakeup or not * @param isNebulaOnly Whether to make only nebula connection and not iotc connection * @see InterfaceCtrl.IOTCListener#receiveSessionInfo */ void TK_nebulaConnect(String udid, String credential, String avToken, String realm, boolean isWakeup, boolean isNebulaOnly);</code></pre> <pre><code class="language-java">Example: camera.TK_nebulaBind(udid, Camera.BindType.PIN_CODE, &amp;quot;123456&amp;quot;); camera.TK_registerIOTCListener(new InterfaceCtrl.SimpleIOTCListener(){ @Override public void receiveBindInfo(Camera camera, String credential, int resultCode, int p2pCode) { if(resultCode == Camera.CONNECTION_STATE_CONNECTED){ //nebula bind success camera.TK_nebulaConnect(udid, credential, avToken, realm, true, false); } } @Override public void receiveSessionInfo(Camera camera, int resultCode, int p2pCode) { if(resultCode == Camera.CONNECTION_STATE_CONNECTED){ //nebula connect success } } });</code></pre> <h4>TK_nebulaLanSearch</h4> <pre><code class="language-java">/** * Nebula When adding AP mode, search the local udid list * &amp;lt;p&amp;gt; * Only for AP mode addition process * * @param timeoutMs timeout * @return udid list */ public static st_UDIDInfo[] TK_nebulaLanSearch(int timeoutMs)</code></pre> <pre><code class="language-java">Example: st_UDIDInfo[] lanSearch = Camera.TK_nebulaLanSearch(5 * 1000); if (lanSearch != null &amp;amp;&amp;amp; lanSearch.length &amp;gt; 0) { String udid = new String(lanSearch[0].UDID); } else { Log.e(TAG, &amp;quot;TK_nebulaLanSearch lanSearch = null&amp;quot;); }</code></pre> <h4>TK_nebulaSsidListReq</h4> <pre><code class="language-java">/** * Nebula When adding AP mode, send local commands to obtain the device wifi list * &amp;lt;p&amp;gt; * You need to call {@link #TK_nebulaStartBind} first for AP mode binding. * * @return wifi list */ List&amp;lt;NebulaWiFiConfig.NebulaIOCtrlMsgSSIDListResp&amp;gt; TK_nebulaSsidListReq();</code></pre> <h4>TK_nebulaSetWifiReq</h4> <pre><code class="language-java">/** * Nebula When adding AP mode, send local instructions to set wifi for the device * &amp;lt;p&amp;gt; * You need to call {@link #TK_nebulaSsidListReq} first to obtain wifi information * * @param wifi wifi information * @param password device password * @return set result */ NebulaWiFiConfig.NebulaIOCtrlMsgSetWifiResp TK_nebulaSetWifiReq(NebulaWiFiConfig.NebulaIOCtrlMsgSSIDListResp wifi, String password);</code></pre> <h4>TK_nebulaSetRegionReq</h4> <pre><code class="language-java">/** * Nebula When adding AP mode, send local commands to set up P2P partition distribution for the device. * &amp;lt;p&amp;gt; * You need to call {@link #TK_nebulaStartBind} first for AP mode binding. * * @param region 0: All; 1: Greater China; 2: Europe; 3: Americas. * @return set result */ NebulaWiFiConfig.NebulaIOCtrlMsgSetRegionResp TK_nebulaSetRegionReq(TUTKRegion region);</code></pre> <h3>1.3.3 common api</h3> <h4>TK_disconnect</h4> <pre><code class="language-java">/** * Disconnect Device and disconnect all internal AV channels at the same time */ public abstract void TK_disconnect();</code></pre> <pre><code class="language-java">Example: camera.TK_disconnect();</code></pre> <h4>TK_start</h4> <pre><code class="language-java">/** * Connect AV channel * &amp;lt;p&amp;gt; * 1、SecurityMode The encryption mode will give priority to the method after the last successful connection, and the default is AUTO(2) * 2、AuthType The authentication method defaults to PASSWORD(0) method * &amp;lt;p&amp;gt; * 1、Need to call {@link #TK_connect} first * 2、The connection result is obtained using {@link #TK_registerIOTCListener} * * @param avChannel generally 0 * @param password password * @see InterfaceCtrl.IOTCListener#receiveChannelInfo */ public abstract void TK_start(int avChannel, String password); /** * Connect AV channel * &amp;lt;p&amp;gt; * 1、Need to call first{@link #TK_connect} * 2、The connection result is obtained using {@link #TK_registerIOTCListener} * * @param avChannel Generally 0 * @param password password * @param account account, usuallyadmin * @param type verification method PASSWORD(0), TOKEN(1); * @param mode encryption mode SIMPLE(0), DTLS(1), AUTO(2); * @see InterfaceCtrl.IOTCListener#receiveChannelInfo */ public abstract void TK_start(int avChannel, String password, String account, Camera.AuthType type, Camera.SecurityMode mode);</code></pre> <pre><code class="language-java">Example: Camera camera = new Camera(); camera.TK_connect(uid, authKey); camera.TK_start(Camera.DEFAULT_AV_CHANNEL, password, &amp;quot;admin&amp;quot;, Camera.AuthType.PASSWORD, Camera.SecurityMode.AUTO); cameraTK_registerIOTCListener(new InterfaceCtrl.SimpleIOTCListener() { @Override public void receiveSessionInfo(Camera camera, int resultCode) { if (resultCode == Camera.CONNECTION_STATE_CONNECTED) { //connect success } } @Override public void receiveChannelInfo(Camera camera, int avChannel, int resultCode) { if (resultCode == Camera.CONNECTION_STATE_CONNECTED) { //Successfully connected av channel } } });</code></pre> <h4>TK_stop</h4> <pre><code class="language-java">/** * Disconnected AV channel * * @param avChannel Generally 0 */ public abstract void TK_stop(int avChannel);</code></pre> <pre><code class="language-java">Example: camera.TK_stop(Camera.DEFAULT_AV_CHANNEL);</code></pre> <h4>TK_changeAuthKey</h4> <pre><code class="language-java">/** * Modify AuthKey and return the modified AuthKey * &amp;lt;p&amp;gt; * Needs to be called after {@link #TK_start} is successful * * @param avChannel Generally 0 */ public abstract String TK_changeAuthKey(int avChannel);</code></pre> <pre><code class="language-java">Example: Camera camera = new Camera(); camera.TK_connect(uid, authKey); camera.TK_start(Camera.DEFAULT_AV_CHANNEL, password, &amp;quot;admin&amp;quot;, Camera.AuthType.PASSWORD, Camera.SecurityMode.AUTO); cameraTK_registerIOTCListener(new InterfaceCtrl.SimpleIOTCListener() { @Override public void receiveSessionInfo(Camera camera, int resultCode) { if (resultCode == Camera.CONNECTION_STATE_CONNECTED) { //connect success } } @Override public void receiveChannelInfo(Camera camera, int avChannel, int resultCode) { if (resultCode == Camera.CONNECTION_STATE_CONNECTED) { //The av channel is successfully connected and the authKey is modified. camera.TK_changeAuthKey(avChannel); } } });</code></pre> <h4>TK_isSessionConnected</h4> <pre><code class="language-java">/** * whether iotc connect or not * */ public abstract boolean TK_isSessionConnected();</code></pre> <pre><code class="language-java">Example: camera.TK_isSessionConnected();</code></pre> <h4>TK_isChannelConnected</h4> <pre><code class="language-java">/** * whether av connect or not * * @param avChannel Generally 0 */ public abstract boolean TK_isChannelConnected(int avChannel);</code></pre> <pre><code class="language-java">Example: camera.TK_isChannelConnected();</code></pre> <h4>TK_getAVChannelCount</h4> <pre><code class="language-java">/** * Get the number of AV channels that have been opened */ public abstract int TK_getAVChannelCount();</code></pre> <pre><code class="language-java">Example: camera.TK_getAVChannelCount();</code></pre> <h4>TK_getServiceTypeOfChannel</h4> <pre><code class="language-java">/** * Get the corresponding channel ServiceTYpe * * @param avChannel Generally 0 * @return return ServiceTYpe */ public abstract long TK_getServiceTypeOfChannel(int avChannel);</code></pre> <pre><code class="language-java">Example: camera.TK_getServiceTypeOfChannel(Camera.DEFAULT_AV_CHANNEL);</code></pre> <h2>1.4 Video processing interface</h2> <h3>TK_startShow</h3> <pre><code class="language-java">/** * Enable video reception, decoding, and playback * &amp;lt;p&amp;gt; * The default is hard decoding, no P frames are lost, and the output data is empty. * &amp;lt;p&amp;gt; * Use {@link #TK_registerMediaDataListener} to get video data * * @param avChannel Generally 0 * @param isDecodeAndRender whether decode and render or not , default yes * @param runSoftwareDecode whether software decode or not , default no * @param isDropFrame whether drop p frame or not, default no * @param type decode data type ,default null * @see InterfaceCtrl.MediaDataListener#onDecodeVideoData * @see InterfaceCtrl.MediaDataListener#onRecvVideoFrame * @see InterfaceCtrl.MediaDataListener#onRecvVideoInfo */ public abstract void TK_startShow(int avChannel); /** * Enable video reception, decoding, and playback * &amp;lt;p&amp;gt; * Use {@link #TK_registerMediaDataListener} to get video data * &amp;lt;p&amp;gt; * The output data type is as follows: * {@link com.tutk.IOTC.Camera.RenderType#OUTPUT_NULL}//Only receive, decode and render, the output data is empty * {@link com.tutk.IOTC.Camera.RenderType#OUTPUT_YUV}//Receive, decode, render, and output yuv data (time-consuming) * {@link com.tutk.IOTC.Camera.RenderType#OUTPUT_YUV_NV12}//Receive, decode, render, and output nv12 data (time consuming) * {@link com.tutk.IOTC.Camera.RenderType#OUTPUT_RGB_8888}//Receive, decode, render, and output RGB_8888 data (time-consuming) * {@link com.tutk.IOTC.Camera.RenderType#OUTPUT_RGB_565}//Receive, decode, render, and output RGB_565 data (time consuming) * * @param avChannel Generally 0 * @param isDecodeAndRender Whether to decode and render. When it is false, decoding, rendering and decoded data output will no longer be performed. * @param runSoftwareDecode Whether to use soft decoding. When hard decoding is not supported, it will automatically switch to soft decoding. The specific decoding method is based on the output result of onDecodeVideoData. * @param isDropFrame Whether to drop P frames and only receive I frames * @param sendStartCommand whether send command or not * @param type Output decoded data type * @see InterfaceCtrl.MediaDataListener#onDecodeVideoData * @see InterfaceCtrl.MediaDataListener#onRecvVideoFrame * @see InterfaceCtrl.MediaDataListener#onRecvVideoInfo */ public abstract void TK_startShow(int avChannel, boolean isDecodeAndRender, boolean runSoftwareDecode, boolean isDropFrame, boolean sendStartCommand , Camera.RenderType type);</code></pre> <pre><code class="language-java">Example: camera.TK_startShow(Camera.DEFAULT_AV_CHANNEL, true, false, false, Camera.RenderType.OUTPUT_NULL); camera.TK_registerMediaDataListener(new InterfaceCtrl.SimpleMediaDataListener() { @Override public void onDecodeVideoData(Camera camera, int avChannel, AVFrame avFrame, byte[] decodeAfter, int videoWidth, int videoHeight, boolean isSoftwareDecode) { //Video decoding data callback } @Override public void onRecvVideoInfo(Camera camera, int avChannel, long bitRate, int frameRate, int onlineNm, int frameCount, int incompleteFrameCount) { //Video debugging information callback } @Override public void onRecvVideoFrame(Camera camera, int avChannel, AVFrame avFrame) { //Video receiving raw data callback } }); }</code></pre> <h3>TK_stopShow</h3> <pre><code class="language-java">/** * Stop video reception, decoding, and playback of all AV channels */ public abstract void TK_stopShow(); /** * Stop video reception, decoding, and playback of current channel * * @param avChannel Channel that needs to be stopped * @param sendStopCommand whether stop sending command or not */ public abstract void TK_stopShow(int avChannel, boolean sendStopCommand);</code></pre> <pre><code class="language-java">Example: camera.TK_stopShow();</code></pre> <h3>TK_getVideoCodecId</h3> <pre><code class="language-java">/** * Get the current video format * &amp;lt;p&amp;gt; * After rendering the picture, you can use this API to obtain the video format * &amp;lt;p&amp;gt; * The corresponding format is as follows: * {@link com.tutk.IOTC.AVFrame#VIDEO_CODEC_MPEG4} 76 * {@link com.tutk.IOTC.AVFrame#VIDEO_CODEC_H263} 77 * {@link com.tutk.IOTC.AVFrame#VIDEO_CODEC_H264} 78 * {@link com.tutk.IOTC.AVFrame#VIDEO_CODEC_MJPEG} 79 * {@link com.tutk.IOTC.AVFrame#VIDEO_CODEC_HEVC} 80 * {@link com.tutk.IOTC.AVFrame#VIDEO_CODEC_VP8} 81 * {@link com.tutk.IOTC.AVFrame#VIDEO_CODEC_VP9} 82 * * @param channel Generally 0 * @return return video format */ int TK_getVideoCodecId(int channel);</code></pre> <pre><code class="language-java">Example: camera.TK_getVideoCodecId(Camera.DEFAULT_AV_CHANNEL);</code></pre> <h3>TK_setAVFilter</h3> <pre><code class="language-java">/** * whether start filter or not * &amp;lt;p&amp;gt; * After drawing the picture, you can use this API to turn on/off the filter. * &amp;lt;p&amp;gt; * When the decoding type is hard decoding and RenderType is OUTPUT_NULL, filters are not supported. * * @param avChannel generally 0 * @param cmd Filter commands (e.g.:eq=contrast=0.9:brightness=0.1:saturation=1 ) * contrast - a floating point number between -2.0 and 2.0, default is 0 * brightness - a floating point number between -1.0 and 1.0, default is 0 * saturation - a floating point number between 0 and 3.0, default is 1 * gamma - a floating point number between 0 and 10.0, default is 1 * gamma_r The red value must be a floating point number between 0.1-10.0, the default is 1 * gamma_g The green value must be a floating point number between 0.1-10.0, the default is 1 * gamma_b The blue value must be a floating point number between 0.1-10.0, the default is 1 * gamma_weight Set the gamma weight expression. It can be used to reduce the impact of high gamma values in bright image areas, such as just plain white amplification, while leaving everything else unchanged. * The value must be a floating point number in the range 0.0 to 1.0. A value of 0.0 has the strongest gamma correction effect, and a value of 1.0 has no effect. The default setting is &amp;quot;1&amp;quot; * @param isStartFilter whether start filter or not */ public abstract void TK_setAVFilter(int avChannel, String cmd, boolean isStartFilter);</code></pre> <pre><code class="language-java">Example: boolean decodeSuucess = false; camera.TK_startShow(Camera.DEFAULT_AV_CHANNEL, false, false, Camera.RenderType.OUTPUT_NULL); camera.TK_registerMediaDataListener(new InterfaceCtrl.SimpleMediaDataListener() { @Override public void onDecodeVideoData(Camera camera, int avChannel, AVFrame avFrame, byte[] decodeAfter, int videoWidth, int videoHeight, boolean isSoftwareDecode) { //Video decoding data callback decodeSuucess = true; } }); } btn.setOnclickListener(new View.OnClickListener{v-&amp;gt; if(decodeSuucess){ camera.TK_setAVFilter(Camera.DEFAULT_AV_CHANNEL, &amp;quot;eq=contrast=0.9:brightness=0.1:saturation=1&amp;quot;, true); } });</code></pre> <h3>TK_setDecodeDelayTime</h3> <pre><code class="language-java">/** * Set the maximum decoding delay and adjust the decoding time interval of each frame * &amp;lt;p&amp;gt; * * @param channel generally 0 * @param delayTime maximum delay time(ms) * @param durationTime decoding time interval(ms) 0 ~ 30 * @see InterfaceCtrl.IRegisterVideoDataListener#onRecvVideoFrame */ public abstract void TK_setDecodeDelayTime(int channel, long delayTime, long durationTime);</code></pre> <pre><code class="language-java">Example: Camera camera = new Camera(); camera.TK_connect(uid, authKey); camera.TK_start(Camera.DEFAULT_AV_CHANNEL, password, &amp;quot;admin&amp;quot;, Camera.AuthType.PASSWORD, Camera.SecurityMode.AUTO); cameraTK_registerIOTCListener(new InterfaceCtrl.SimpleIOTCListener() { @Override public void receiveChannelInfo(Camera camera, int avChannel, int resultCode) { if (resultCode == Camera.CONNECTION_STATE_CONNECTED) { //Successfully connected av channel camera.TK_setDecodeDelayTime(Camera.DEFAULT_AV_CHANNEL, 1500, 15); } } });</code></pre> <h2>1.5 audio processing interface</h2> <h3>TK_startSoundToDevice</h3> <pre><code class="language-java">/** * Start audio collection, encoding, and sending * &amp;lt;p&amp;gt; * 1、Use {@link #TK_registerMediaDataListener} to get audio data * 2、Use {@link #TK_registerIOTCListener} to get whether the audio intercom is successful * 3、After the audio intercom starts, a {@link com.tutk.IOTC.Camera#ACTION_START_SOUND_TO_DEVICE} broadcast is sent * 4、After the audio intercom ends, a {@link com.tutk.IOTC.Camera#ACTION_STOP_SOUND_TO_DEVICE} broadcast will be sent * * @param channel generally 0 * @see InterfaceCtrl.MediaDataListener#onSendAudioFrame * @see InterfaceCtrl.IOTCListener#receiveSoundToDevice */ void TK_startSoundToDevice(int channel); /** * Start audio collection, encoding, and sending * &amp;lt;p&amp;gt; * 1、Use {@link #TK_registerMediaDataListener} to get audio data * 2、Use {@link #TK_registerIOTCListener} to get whether the audio intercom is successful * 3、After the audio intercom starts, a {@link com.tutk.IOTC.Camera#ACTION_START_SOUND_TO_DEVICE} broadcast is sent * 4、After the audio intercom ends, a {@link com.tutk.IOTC.Camera#ACTION_STOP_SOUND_TO_DEVICE} broadcast will be sent * * @param channel generally 0 * @param isResend whether start resend mode or not * @param captureSize capture size of audio size * @see InterfaceCtrl.MediaDataListener#onSendAudioFrame * @see InterfaceCtrl.IOTCListener#receiveSoundToDevice */ void TK_startSoundToDevice(int channel, boolean isResend, int captureSize);</code></pre> <pre><code class="language-java">Example: camera.TK_startSoundToDevice(Camera.DEFAULT_AV_CHANNEL); camera.TK_registerMediaDataListener(new InterfaceCtrl.SimpleMediaDataListener(){ @Override public void onSendAudioFrame(Camera camera, int avChannel, AVFrame avFrame) { //Audio collection raw data callback } });</code></pre> <h3>TK_stopSoundToDevice</h3> <pre><code class="language-java">/** * stop audio collection, encoding, and sending * * @param avChannel generally 0 */ public abstract void TK_stopSoundToDevice(int avChannel);</code></pre> <pre><code class="language-java">Example: camera.TK_stopSoundToDevice(Camera.DEFAULT_AV_CHANNEL);</code></pre> <h3>TK_startSoundToPhone</h3> <pre><code class="language-java">/** * Start audio reception, decoding, and playback * &amp;lt;p&amp;gt; * 1、Use {@link #TK_registerMediaDataListener} to get audio data * 2、Use {@link #TK_registerIOTCListener} to get whether the audio playback is successful * 3、After audio playback starts, a {@link com.tutk.IOTC.Camera#ACTION_START_SOUND_TO_PHONE} broadcast is sent * 4、After the audio playback ends, a {@link com.tutk.IOTC.Camera#ACTION_STOP_SOUND_TO_PHONE} broadcast is sent * * @param channel generally 0 * @see InterfaceCtrl.MediaDataListener#onRecvAudioFrame * @see InterfaceCtrl.MediaDataListener#onDecodeAudioData * @see InterfaceCtrl.IOTCListener#receiveSoundToPhone */ void TK_startSoundToPhone(int channel); /** * Start audio reception, decoding, and playback * &amp;lt;p&amp;gt; * 1、Use {@link #TK_registerMediaDataListener} to get audio data * 2、Use {@link #TK_registerIOTCListener} to get whether the audio playback is successful * 3、After audio playback starts, a {@link com.tutk.IOTC.Camera#ACTION_START_SOUND_TO_PHONE} broadcast is sent * 4、After the audio playback ends, a {@link com.tutk.IOTC.Camera#ACTION_STOP_SOUND_TO_PHONE} broadcast is sent * * @param channel generally 0 * @param isDecodeAndPlay whether decode and render or not * @see InterfaceCtrl.MediaDataListener#onRecvAudioFrame * @see InterfaceCtrl.MediaDataListener#onDecodeAudioData * @see InterfaceCtrl.IOTCListener#receiveSoundToPhone */ void TK_startSoundToPhone(int channel, boolean isDecodeAndPlay);</code></pre> <pre><code class="language-java">Example: camera.TK_startSoundToPhone(Camera.DEFAULT_AV_CHANNEL); camera.TK_registerMediaDataListener(new InterfaceCtrl.SimpleMediaDataListener(){ @Override public void onDecodeAudioData(Camera camera, int avChannel, AVFrame avFrame, byte[] decodeAfter) { //Audio decoding data callback } @Override public void onRecvAudioFrame(Camera camera, int avChannel, AVFrame avFrame) { //Audio receiving raw data callback } });</code></pre> <h3>TK_stopSoundToPhone</h3> <pre><code class="language-java">/** * Stop audio reception, decoding, and playback * * @param avChannel generally 0 */ public abstract void TK_stopSoundToPhone(int avChannel);</code></pre> <pre><code class="language-java">Example: camera.TK_stopSoundToPhone(Camera.DEFAULT_AV_CHANNEL);</code></pre> <h3>TK_setAudioCustom</h3> <pre><code class="language-java">/** * Whether you need to play or send audio yourself, generally used for third-party echo cancellation functions * &amp;lt;p&amp;gt; * 1、Use this API to tell the underlying layer not to play, encode or send audio. * 2、Use {@link #TK_startSoundToPhone} to start audio reception and decoding (no playback will be performed internally) * 3、Use {@link #TK_startSoundToDevice} to start audio collection (encoding and sending are no longer performed internally) * 4、Use {@link #TK_registerMediaDataListener} to obtain decoded audio data and obtain collected audio data * 5、Use {@link #TK_playAudio} to play audio data after echo cancellation * 6、Use {@link #TK_sendAudio} to send echo-cancelled audio data * * @param customPlay After setting to true, the bottom layer only does audio reception and decoding, and no longer plays it. * @param customSend After setting it to true, the bottom layer only performs audio collection, and no longer performs encoding and sending. */ public abstract void TK_setAudioCustom(int avChannel, boolean customPlay, boolean customSend);</code></pre> <pre><code class="language-java">Example: camera.TK_setAudioCustom(Camera.DEFAULT_AV_CHANNEL, true, true); camera.TK_startSoundToPhone(Camera.DEFAULT_AV_CHANNEL); camera.TK_stopSoundToDevice(Camera.DEFAULT_AV_CHANNEL); camera.TK_registerMediaDataListener(new InterfaceCtrl.SimpleMediaDataListener(){ @Override public void onRecvAudioFrame(Camera camera, int avChannel, AVFrame avFrame) { //The audio receives the original data callback and performs the echo elimination logic on its own after obtaining it. byte[] audioData = test1(avFrame.frmData); //Play it yourself, or use this API to play it mCamera.TK_playAudio(avChannel, audioData, audioData.length, (int)System.currentTimeMillis()); } @Override public void onSendAudioFrame(Camera camera, int avChannel, AVFrame avFrame) { //Audio collection raw data callback, after acquisition, the echo elimination logic is performed by itself byte[] audioData = test2(avFrame.frmData); //send data mCamera.TK_sendAudio(avChannel, audioData, audioData.length); } });</code></pre> <h3>TK_playAudio</h3> <pre><code class="language-java">/** * Play audio data after echo cancellation, generally used for third-party echo cancellation functions * &amp;lt;p&amp;gt; * 1、Use {@link #TK_setAudioCustom} to tell the bottom layer not to play audio * 2、Use {@link #TK_startSoundToPhone} to start audio reception and decoding (no longer playback) * 3、Use {@link #TK_registerMediaDataListener} to get the decoded audio data * 4、Use this API to play audio data after echo cancellation * * @param bytes audio data * @param length audio data length * @param channel channel * @param timestamp relative timestamp * @see InterfaceCtrl.MediaDataListener#onRecvAudioFrame */ public abstract void TK_playAudio(int channel, byte[] bytes, int length, int timestamp);</code></pre> <pre><code class="language-java">Example:Consistent with the TK_setAudioCustom example</code></pre> <h3>TK_sendAudio</h3> <pre><code class="language-java">/** * Send audio data after echo cancellation, generally used for third-party echo cancellation functions * &amp;lt;p&amp;gt; * 1、Use {@link #TK_setAudioCustom} to tell the bottom layer not to encode and send audio. * 2、Use {@link #TK_startSoundToDevice} to start audio collection (no more encoding and sending) * 3、Use {@link #TK_registerMediaDataListener} to get the collected data * 4、Use this API to send audio data after echo cancellation * * @param avChannel channel * @param bytes audio data * @param length audio data length * @see InterfaceCtrl.MediaDataListener#onSendAudioFrame */ public abstract void TK_sendAudio(int avChannel, byte[] bytes, int length);</code></pre> <pre><code class="language-java">Example:Consistent with the TK_setAudioCustom example</code></pre> <h3>TK_setSoundToDeviceFormats</h3> <pre><code class="language-java">/** * Set audio intercom format, sampling rate, etc. * &amp;lt;p&amp;gt; * Using {@link #TK_startSoundToDevice} will adopt the configuration of this Api * * @param channel generally 0 * @param audioSpeakCodec audio format * {@link com.tutk.IOTC.AVFrame#AUDIO_CODEC_AAC_RAW} 134 * {@link com.tutk.IOTC.AVFrame#AUDIO_CODEC_AAC_ADTS} 135 * {@link com.tutk.IOTC.AVFrame#AUDIO_CODEC_AAC_LATM} 136 * {@link com.tutk.IOTC.AVFrame#AUDIO_CODEC_G711U} 137 * {@link com.tutk.IOTC.AVFrame#AUDIO_CODEC_G711A} 138 * {@link com.tutk.IOTC.AVFrame#AUDIO_CODEC_ADPCM} 139 * {@link com.tutk.IOTC.AVFrame#AUDIO_CODEC_PCM} 140 * {@link com.tutk.IOTC.AVFrame#AUDIO_CODEC_SPEEX} 141 * {@link com.tutk.IOTC.AVFrame#AUDIO_CODEC_MP3} 142 * {@link com.tutk.IOTC.AVFrame#AUDIO_CODEC_G726} 143 * @param audioSampleRate sample rate * {@link com.tutk.IOTC.AVFrame#AUDIO_SAMPLE_8K} 8000 * {@link com.tutk.IOTC.AVFrame#AUDIO_SAMPLE_16K} 16000 * @param channelConfig audio config * {@link com.tutk.IOTC.AVFrame#AUDIO_CHANNEL_MONO} 0 * {@link com.tutk.IOTC.AVFrame#AUDIO_CHANNEL_STERO} 1 * @param audioDataBits PCM data bits * {@link com.tutk.IOTC.AVFrame#AUDIO_DATABITS_8} 0 * {@link com.tutk.IOTC.AVFrame#AUDIO_DATABITS_16} 1 */ void TK_setSoundToDeviceFormats(int channel, int audioSpeakCodec, int audioSampleRate, int channelConfig, int audioDataBits);</code></pre> <pre><code class="language-java">Example: camera.TK_setSoundToDeviceFormats(Camera.DEFAULT_AV_CHANNEL, AVFrame.AUDIO_CODEC_G711A, AVFrame.AUDIO_SAMPLE_8K, AVFrame.AUDIO_CHANNEL_MONO, AVFrame.AUDIO_DATABITS_16);</code></pre> <h3>TK_getSoundToDeviceCodecId</h3> <pre><code class="language-java">/** * Get audio intercom format * &amp;lt;p&amp;gt; * The corresponding format is as follows: * {@link com.tutk.IOTC.AVFrame#AUDIO_CODEC_AAC_RAW} 134 * {@link com.tutk.IOTC.AVFrame#AUDIO_CODEC_AAC_ADTS} 135 * {@link com.tutk.IOTC.AVFrame#AUDIO_CODEC_AAC_LATM} 136 * {@link com.tutk.IOTC.AVFrame#AUDIO_CODEC_G711U} 137 * {@link com.tutk.IOTC.AVFrame#AUDIO_CODEC_G711A} 138 * {@link com.tutk.IOTC.AVFrame#AUDIO_CODEC_ADPCM} 139 * {@link com.tutk.IOTC.AVFrame#AUDIO_CODEC_PCM} 140 * * @param channel generally 0 * @return return audio format */ int TK_getSoundToDeviceCodecId(int channel);</code></pre> <pre><code class="language-java">Example: camera.TK_getSoundToDeviceCodecId(Camera.DEFAULT_AV_CHANNEL);</code></pre> <h3>TK_getSoundToPhoneCodecId</h3> <pre><code class="language-java">/** * Get audio monitoring format * &amp;lt;p&amp;gt; * corresponding format is as follows: * {@link com.tutk.IOTC.AVFrame#AUDIO_CODEC_AAC_RAW} 134 * {@link com.tutk.IOTC.AVFrame#AUDIO_CODEC_AAC_ADTS} 135 * {@link com.tutk.IOTC.AVFrame#AUDIO_CODEC_AAC_LATM} 136 * {@link com.tutk.IOTC.AVFrame#AUDIO_CODEC_G711U} 137 * {@link com.tutk.IOTC.AVFrame#AUDIO_CODEC_G711A} 138 * {@link com.tutk.IOTC.AVFrame#AUDIO_CODEC_ADPCM} 139 * {@link com.tutk.IOTC.AVFrame#AUDIO_CODEC_PCM} 140 * * @param channel generally 0 * @return return audio format */ int TK_getSoundToPhoneCodecId(int channel);</code></pre> <pre><code class="language-java">Example: camera.TK_getSoundToPhoneCodecId(Camera.DEFAULT_AV_CHANNEL);</code></pre> <h3>TK_setSoundToDeviceCaptureSource</h3> <p>[android耳机适配示例.zip](<a href="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=907628412187644f64f49a3363c1649d">https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=907628412187644f64f49a3363c1649d</a> &quot;[android耳机适配示例.zip&quot;)</p> <pre><code class="language-java">/** * Set the audio intercom collection source and collection audio gain, which can be used to adapt the headset function(refer to &amp;lt;android耳机适配示例&amp;gt;) * &amp;lt;p&amp;gt; * Using {@link #TK_startSoundToDevice} will adopt the configuration of this Api * * @param audioSource Audio collection source, default isVOICE_COMMUNICATION * {@link android.media.MediaRecorder.AudioSource#MIC} * {@link android.media.MediaRecorder.AudioSource#VOICE_UPLINK} * {@link android.media.MediaRecorder.AudioSource#VOICE_DOWNLINK} * {@link android.media.MediaRecorder.AudioSource#VOICE_CALL} * {@link android.media.MediaRecorder.AudioSource#CAMCORDER} * {@link android.media.MediaRecorder.AudioSource#VOICE_RECOGNITION} * {@link android.media.MediaRecorder.AudioSource#VOICE_COMMUNICATION} * @param audioSpeakGain Audio gain, default is 2f */ public static void TK_setSoundToDeviceCaptureSource(int audioSource, float audioSpeakGain);</code></pre> <pre><code class="language-java">Example: camera.TK_setSoundToDeviceCaptureSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION, 2f);</code></pre> <h3>TK_setSoundToPhonePlaySource</h3> <p>[android耳机适配示例.zip](<a href="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=907628412187644f64f49a3363c1649d">https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=907628412187644f64f49a3363c1649d</a> &quot;[android耳机适配示例.zip&quot;)</p> <pre><code class="language-java">/** * Set the playback source for audio monitoring, which can be used to adapt the headphone function(refer to &amp;lt;android耳机适配示例&amp;gt;) * &amp;lt;p&amp;gt; * Using {@link #TK_startSoundToPhone} will adopt the configuration of this Api * * @param audioStreamType Audio playback source, default isSTREAM_VOICE_CALL * {@link android.media.AudioManager#STREAM_VOICE_CALL} * {@link android.media.AudioManager#STREAM_SYSTEM} * {@link android.media.AudioManager#STREAM_RING} * {@link android.media.AudioManager#STREAM_MUSIC} * {@link android.media.AudioManager#STREAM_ALARM} * {@link android.media.AudioManager#STREAM_NOTIFICATION} */ public static void TK_setSoundToPhonePlaySource(int audioStreamType);</code></pre> <pre><code class="language-java">Example: camera.TK_setSoundToPhonePlaySource(AudioManager.STREAM_VOICE_CALL);</code></pre> <h2>1.6 recorder and snapshot</h2> <h3>TK_startRecording</h3> <pre><code class="language-java">/** * start recording * &amp;lt;p&amp;gt; *The UI will be stuck, please put a sub-thread to operate. * * @param channel generally 0 * @param path record store path */ public abstract boolean TK_startRecording(int channel, String path);</code></pre> <pre><code class="language-java">Example: camera.TK_startRecording(Camera.DEFAULT_AV_CHANNEL, path);</code></pre> <h3>TK_stopRecording</h3> <pre><code class="language-java">/** * stop recording */ public abstract boolean TK_stopRecording(int channel);</code></pre> <pre><code class="language-java">Example: camera.TK_stopRecording(Camera.DEFAULT_AV_CHANNEL);</code></pre> <h3>TK_snapshot</h3> <pre><code class="language-java">/** * image snapshot * &amp;lt;p&amp;gt; * The UI will be stuck, please put a sub-thread to operate. * * @param channel av channel * @param filePath snapshot store path * @param bitmapPixels The maximum pixel value of the image, 0 represents the default maximum valueLong.MAX_VALUE * @return whether snapshot or not */ public abstract boolean TK_snapshot(int channel, String filePath, long bitmapPixels);</code></pre> <pre><code class="language-java">Example: camera.TK_snapshot(Camera.DEFAULT_AV_CHANNEL, path, 0);</code></pre> <h2>1.7 send command</h2> <h3>1.7.1 P2P</h3> <h4>TK_sendIOCtrlToChannel</h4> <pre><code class="language-java">/** * send command to device * * @param avChannel generally 0 * @param type command type * @param data command data */ public abstract void TK_sendIOCtrlToChannel(int avChannel, int type, byte[] data);</code></pre> <pre><code class="language-java">Example: camera.TK_sendIOCtrlToChannel(Camera.DEFAULT_AV_CHANNEL, 0x1ff, new byte[]{0, 0, 0, 0});</code></pre> <h4>TK_sendJsonCtrlToChannel</h4> <pre><code class="language-java">/** * send json command to device * * @param avChannel av channel:generally 0 * @param jsonRequest sennd json command * @param jsonResponse get response of command * @param timeoutSec timeout */ public abstract void TK_sendJsonCtrlToChannel(int avChannel, String jsonRequest, int timeoutSec);</code></pre> <pre><code class="language-java">Example: camera.TK_sendJsonCtrlToChannel(Camera.DEFAULT_AV_CHANNEL, jsonRequest, 2);</code></pre> <h4>TK_removeAllCmd</h4> <pre><code class="language-java">/** * remove command queue */ public abstract void TK_removeAllCmd();</code></pre> <pre><code class="language-java">Example: camera.TK_removeAllCmd();</code></pre> <h3>1.7.2 Nebula</h3> <h4>TK_nebulaSendData</h4> <pre><code class="language-java">/** * Nebula send json command * &amp;lt;p&amp;gt; * Use {@link #TK_registerIOTCListener} to get the sending result * * @param jsonRequest snd json command * @param timeoutMs timeout * @see InterfaceCtrl.IOTCListener#sendJsonCtrlData */ void TK_nebulaSendData(String jsonRequest, int timeoutMs);</code></pre> <pre><code class="language-java">Example: JSONObject jsonObject = new JSONObject(); try { JSONObject args = new JSONObject(); args.put(&amp;quot;value&amp;quot;, true); jsonObject.put(&amp;quot;func&amp;quot;, &amp;quot;startVideo&amp;quot;); jsonObject.put(&amp;quot;args&amp;quot;, args); } catch (JSONException e) { e.printStackTrace(); } camera.TK_nebulaSendData(jsonObject.toString(), 1000);</code></pre> <h2>1.8 download and upload file</h2> <h3>TK_startDownload</h3> <pre><code class="language-java">/** * start download file * &amp;lt;p&amp;gt; * Use {@link #TK_registerIOTCListener} to get download progress * * @param type transfer type * @param dirPath sandbox path * @param channel channel * @see InterfaceCtrl.IOTCListener#downloadUploadOutput */ void TK_startDownload(Camera.TKTransferType type, String dirPath, int channel);</code></pre> <pre><code class="language-java">Example: // Send command to get the list of device file names TK_commandGetFileList(channel, startTime, endTime, fileType, new CommandListener&amp;lt;CommandGetListFile&amp;gt;() { @Override public void onResponse(@Nullable CommandGetListFile command) { //Send command to obtain device download channel list TK_commandDownloadFile(command.list, new CommandListener&amp;lt;CommandDownloadFile&amp;gt;() { @Override public void onResponse(@Nullable CommandDownloadFile command) { //start download file String dirPath = &amp;quot;/sdcard/Android/data/com.tutk.kalay/file&amp;quot;; for (Integer channel : command.list) { camera.TK_startDownload(TKTransferType.valueOf(String.valueOf(command.type)), dirPath, channel); } } }); } });</code></pre> <h3>TK_stopDownload</h3> <pre><code class="language-java">/** * stop download file * * @param type transfer type * @param channel channel */ void TK_stopDownload(Camera.TKTransferType type, int channel);</code></pre> <h3>TK_startUpload</h3> <pre><code class="language-java">/** * start upload file * &amp;lt;p&amp;gt; * Use {@link #TK_registerIOTCListener} to get upload progress * * @param type transfer type * @param filePath sandbox path * @param channel channel * @see InterfaceCtrl.IOTCListener#downloadUploadOutput */ void TK_startUpload(Camera.TKTransferType type, String filePath, int channel);</code></pre> <pre><code class="language-java">Example: //upload filelist ArrayList&amp;lt;String&amp;gt; filePathList = new ArrayList(); filePathList.add(&amp;quot;/sdcard/Android/data/com.tutk.kalay/file1.mp4&amp;quot;); filePathList.add(&amp;quot;/sdcard/Android/data/com.tutk.kalay/file2.jpg&amp;quot;); filePathList.add(&amp;quot;/sdcard/Android/data/com.tutk.kalay/file3.zip&amp;quot;); filePathList.add(&amp;quot;/sdcard/Android/data/com.tutk.kalay/file4.mp3&amp;quot;); //Get device upload channel list TK_commandUploadFile(filePathList, new CommandListener&amp;lt;CommandUploadFile&amp;gt;() { @Override public void onResponse(@Nullable CommandUploadFile command) { //start upload file int index = -1; for (Integer channel : command.list) { index++; if (index &amp;gt;= command.list.size()) { index = 0; } TK_startUpload(TKTransferType.valueOf(String.valueOf(command.type)), filePathList.get(index), channel); } } });</code></pre> <h3>TK_stopUpload</h3> <pre><code class="language-java">/** * stop upload file * * @param type transfer file * @param channel channel */ void TK_stopUpload(Camera.TKTransferType type, int channel);</code></pre> <h1>二、KalayCameraControl(command encapsulation)</h1> <h2>2.1 TK_commandSetRecord</h2> <pre><code class="language-java">/** * Set the device SD card recording mode * * @param channel Camera Index * @param recordType refer to {@link AVIOCTRLDEFs#AVIOTC_RECORDTYPE_OFF} */ public void TK_commandSetRecord(int channel, int recordType, CommandListener&amp;lt;CommandSetRecord&amp;gt; listener)</code></pre> <h2>2.2 TK_commandGetRecord</h2> <pre><code class="language-java">/** *Get the device SD card recording mode * * @param channel Camera Index */ public void TK_commandGetRecord(int channel, CommandListener&amp;lt;CommandGetRecordMode&amp;gt; listener)</code></pre> <h2>2.3 TK_commandListEvent</h2> <pre><code class="language-java">/** * Get device event list * * @param channel Camera Index * @param startTime starttime of search event ms * @param endTime endtime of search event ms * @param event event type,refer to {@link AVIOCTRLDEFs#AVIOCTRL_EVENT_ALL} */ public void TK_commandListEvent(int channel, long startTime, long endTime, int event, CommandListener&amp;lt;CommandListEvent&amp;gt; listener)</code></pre> <h2>2.4 TK_commandRecordPlayControl</h2> <pre><code class="language-java">/** * control event playback * * @param channel Camera Index * @param command play record command,refer to {@link AVIOCTRLDEFs#AVIOCTRL_RECORD_PLAY_PAUSE} * @param param command param,by user defined。no use for Nebula * @param time starttime of eventlist。no use for Nebula * @param endflag 0 app, end flag of event playback ; 1 web, When this event has finished playing, continue playing the next event。no use for Nebula * @param downloadFlag 0 playback mode, 1 download mode。no use for Nebula * @param fileName filename。no use for AvApi */ public void TK_commandRecordPlayControl(int channel, int command, int param, long time, int endflag, int downloadFlag, String fileName, CommandListener&amp;lt;CommandRecordPlayControl&amp;gt; listener)</code></pre> <h2>2.5 TK_commandSetStreamCtrl</h2> <pre><code class="language-java">/** * set device stream resolution * * @param channel Camera Index * @param quality refer to {@link AVIOCTRLDEFs#AVIOCTRL_QUALITY_MAX} */ public void TK_commandSetStreamCtrl(int channel, int quality, CommandListener&amp;lt;CommandSetStreamCtrl&amp;gt; listener)</code></pre> <h2>2.6 TK_commandGetStreamCtrl</h2> <pre><code class="language-java">/** * get device stream resolution * * @param channel Camera Index */ public void TK_commandGetStreamCtrl(int channel, CommandListener&amp;lt;CommandGetStreamCtrl&amp;gt; listener)</code></pre> <h2>2.7 TK_commandSetMotionDetect</h2> <pre><code class="language-java">/** * set device motion detect * * @param channel Camera Index * @param sensitivity 0 (denied) ~ 100(maxinum): * Index in App. Sensitivity value * 0 0(closed) * 1 25(low) * 2 50(middle) * 3 75(high) * 4 100(highest) */ public void TK_commandSetMotionDetect(int channel, int sensitivity, CommandListener&amp;lt;CommandSetMotionDetect&amp;gt; listener)</code></pre> <h2>2.8 TK_commandGetMotionDetect</h2> <pre><code class="language-java">/** * 获取设备目前位移侦测之灵敏度 * * @param channel Camera Index */ public void TK_commandGetMotionDetect(int channel, CommandListener&amp;lt;CommandGetMotionDetect&amp;gt; listener)</code></pre> <h2>2.9 TK_commandGetSupportStream</h2> <pre><code class="language-java">/** * get device motion detect */ public void TK_commandGetSupportStream(CommandListener&amp;lt;CommandGetSupportStream&amp;gt; listener)</code></pre> <h2>2.10 TK_commandGetAudioOutFormat</h2> <pre><code class="language-java">/** * get audio format * * @param channel Camera Index */ public void TK_commandGetAudioOutFormat(int channel, CommandListener&amp;lt;CommandGetAudioOutFormat&amp;gt; listener)</code></pre> <h2>2.11 TK_commandSetPassword</h2> <pre><code class="language-java">/** * set device password * * @param oldPwd old password * @param newPwd new password */ public void TK_commandSetPassword(String oldPwd, String newPwd, CommandListener&amp;lt;CommandSetPassword&amp;gt; listener)</code></pre> <h2>2.12 TK_commandGetRecordDuration</h2> <pre><code class="language-java">/** * get sd card event total time * * @param channel Camera Index * @param eventTime evnet time */ public void TK_commandGetRecordDuration(int channel, long eventTime, CommandListener&amp;lt;CommandGetRecordDuration&amp;gt; listener)</code></pre> <h2>2.13 TK_commandSetRecordProgress</h2> <pre><code class="language-java">/** * set event playback progress * * @param channel Camera Index * @param eventTime event time */ public void TK_commandSetRecordProgress(int channel, long eventTime, int progressTime, CommandListener&amp;lt;CommandSetRecordProgress&amp;gt; listener)</code></pre> <h2>2.14 TK_commandListWifiAp</h2> <pre><code class="language-java">/** * get device wifi list */ public void TK_commandListWifiAp(CommandListener&amp;lt;CommandListWifiAp&amp;gt; listener)</code></pre> <h2>2.15 TK_commandSetWifi</h2> <pre><code class="language-java">/** * set device wifi network * * @param ssid WiFi SSID * @param password WiFi password * @param mode refer to {@link AVIOCTRLDEFs#AVIOTC_WIFIAPMODE_NULL} * @param enctype refer to {@link AVIOCTRLDEFs#AVIOTC_WIFIAPENC_INVALID} */ public void TK_commandSetWifi(String ssid, String password, int mode, int enctype, CommandListener&amp;lt;CommandSetWifi&amp;gt; listener)</code></pre> <h2>2.16 TK_commandGetWifi</h2> <pre><code class="language-java">/** * get device current wifi */ public void TK_commandGetWifi(CommandListener&amp;lt;CommandGetWifi&amp;gt; listener)</code></pre> <h2>2.17 TK_commandSetVideoMode</h2> <pre><code class="language-java">/** * Set screen mirroring/flip status * * @param channel Camera Index * @param mode refer to {@link AVIOCTRLDEFs#AVIOCTRL_VIDEOMODE_NORMAL} */ public void TK_commandSetVideoMode(int channel, int mode, CommandListener&amp;lt;CommandSetVideoMode&amp;gt; listener)</code></pre> <h2>2.18 TK_commandGetVideoMode</h2> <pre><code class="language-java">/** * Get screen mirroring/flip status */ public void TK_commandGetVideoMode(int channel, CommandListener&amp;lt;CommandGetVideoMode&amp;gt; listener)</code></pre> <h2>2.19 TK_commandFormatExtStorage</h2> <pre><code class="language-java">/** * format SD Card * * @param Storage index(For example sdcard slot = 0, internal flash = 1,...) */ public void TK_commandFormatExtStorage(int Storage, CommandListener&amp;lt;CommandFormatExtStorage&amp;gt; listener)</code></pre> <h2>2.20 TK_commandGetChannelName</h2> <pre><code class="language-java">/** * get all channel name */ public void TK_commandGetChannelName(CommandListener&amp;lt;CommandGetChannelName&amp;gt; listener)</code></pre> <h2>2.21 TK_commandSetChannelName</h2> <pre><code class="language-java">/** * set channel name * * @param channel Camera Index * @param name channel name */ public void TK_commandSetChannelName(int channel, String name, CommandListener&amp;lt;CommandSetChannelName&amp;gt; listener)</code></pre> <h2>2.22 TK_commandXmCall</h2> <pre><code class="language-java">/** * The doorbell answers. When receiving the device doorbell call command, use this API to reply. * * @param channel Camera Index * @param answer 0:hang up;1:answer */ public void TK_commandXmCall(int channel, int answer, CommandListener&amp;lt;CommandXmCall&amp;gt; listener)</code></pre> <h2>2.23 TK_commandSetName</h2> <pre><code class="language-java">/** * set device name * * @param channel Camera Index * @param name device name */ public void TK_commandSetName(int channel, String name, CommandListener&amp;lt;CommandSetName&amp;gt; listener)</code></pre> <h2>2.24 TK_commandSetTimeSync</h2> <pre><code class="language-java">/** * set timesync to device * * @param isSupportSync 1 support; 0 unsupport * @param gmtOffset Offset between GMT (second) */ public void TK_commandSetTimeSync(int year, int month, int day, int hour, int minute, int second, int isSupportSync, int gmtOffset, CommandListener&amp;lt;CommandSetTimeSync&amp;gt; listener)</code></pre> <h2>2.25 TK_commandSetPtz</h2> <pre><code class="language-java">/** * PTZ Control * * @param channel Camera Index * @param control refer to {@link AVIOCTRLDEFs#AVIOCTRL_PTZ_UP} * @param speed The speed of gimbal rotation */ public void TK_commandSetPtz(int channel, int control, int speed, CommandListener&amp;lt;CommandPtz&amp;gt; listener)</code></pre> <h2>2.26 TK_commandOta</h2> <pre><code class="language-java">/** * OTA * * @param url Download firmware url link * @param fileChecksum MD5 Check code * @param fileSize Firmware package size */ public void TK_commandOta(String url, String fileChecksum, int fileSize, CommandListener&amp;lt;CommandOta&amp;gt; listener)</code></pre> <h2>2.27 TK_commandDeviceInfo</h2> <pre><code class="language-java">/** * get device information */ public void TK_commandDeviceInfo(CommandListener&amp;lt;CommandDeviceInfo&amp;gt; listener)</code></pre> <h2>2.28 TK_commandDeviceSupportOta</h2> <pre><code class="language-java">/** * Get whether the device supports OTA upgrade */ public void TK_commandDeviceSupportOta(CommandListener&amp;lt;CommandDeviceSupportOta&amp;gt; listener)</code></pre> <h2>2.29 TK_commandDeviceSupportCloud</h2> <pre><code class="language-java">/** * Get whether the device supports Cloud */ public void TK_commandDeviceSupportCloud(CommandListener&amp;lt;CommandDeviceSupportCloud&amp;gt; listener)</code></pre> <h2>2.30 TK_commandDeviceSetCloud</h2> <pre><code class="language-java">/** * set device cloud record mode * * @param channel Camera Index * @param isOn 1 open, 0 close */ public void TK_commandDeviceSetCloud(int channel, int isOn, CommandListener&amp;lt;CommandDeviceSetCloud&amp;gt; listener)</code></pre> <h2>2.31 TK_commandDeviceGetCloud</h2> <pre><code class="language-java">/** * get device cloud record mode * * @param channel Camera Index */ public void TK_commandDeviceGetCloud(int channel, CommandListener&amp;lt;CommandDeviceGetCloud&amp;gt; listener)</code></pre> <h2>2.32 TK_commandGetEventDate</h2> <pre><code class="language-java">/** * Get the date of SD card event * * @param channel Camera Index * @param eventType Query event type, 0: all, 1: motion detection; 2: full-time recording, default is 0 * @param startTime starttime ms * @param endTime endtime ms */ public void TK_commandGetEventDate(int channel, int eventType, long startTime, long endTime, CommandListener&amp;lt;CommandGetEventDate&amp;gt; listener)</code></pre> <h2>2.33 TK_commandGetHumanDetection</h2> <pre><code class="language-java">/** * Get device humanoid detection switch */ public void TK_commandGetHumanDetection(CommandListener&amp;lt;CommandGetHumanDetection&amp;gt; listener)</code></pre> <h2>2.34 TK_commandSetHumanDetection</h2> <pre><code class="language-java">/** * Set the device humanoid detection switch * * @param isOn 1 open, 0 close */ public void TK_commandSetHumanDetection(int isOn, CommandListener&amp;lt;CommandSetHumanDetection&amp;gt; listener)</code></pre> <h2>2.35 TK_commandGetNightVision</h2> <pre><code class="language-java">/** * get device night vision */ public void TK_commandGetNightVision(CommandListener&amp;lt;CommandGetNightVision&amp;gt; listener)</code></pre> <h2>2.36 TK_commandSetNightVision</h2> <pre><code class="language-java">/** * set device night vision * * @param isOn 1 open, 0 close */ public void TK_commandSetNightVision(int isOn, CommandListener&amp;lt;CommandSetNightVision&amp;gt; listener)</code></pre> <h2>2.37 TK_commandGetSummerTime</h2> <pre><code class="language-java">/** * Get the device summer time */ public void TK_commandGetSummerTime(CommandListener&amp;lt;CommandGetSummerTime&amp;gt; listener)</code></pre> <h2>2.38 TK_commandSetSummerTime</h2> <pre><code class="language-java">/** * set the device summer time * * @param isOn 1 open, 0 close */ public void TK_commandSetSummerTime(int isOn, CommandListener&amp;lt;CommandSetSummerTime&amp;gt; listener)</code></pre> <h1>3、CommandUsage and packaging examples</h1> <h2>3.1 define Command and structure</h2> <pre><code class="language-java">APP sends Command to obtain the status of light control switch:IOTYPE_GET_LED_REQ = 0x30000001 typedef struct { unsigned int channel; //current channel unsigned char reserved[4]; }SMsgAVIoctrlGetLedReq;</code></pre> <pre><code class="language-java">The device returns the status of the light control switch.:IOTYPE_GET_LED_RESP = 0x30000002 typedef struct { int result; //0:success, other fail unsigned char isOnOff; // 0:open; 1:close unsigned char reserved[3]; }SMsgAVIoctrlGetLedResp;</code></pre> <h2>3.2 Encapsulate the structure into byte[] data and send</h2> <pre><code class="language-java">//In the structure SMsgAVIoctrlGetLedReq, because int occupies 4 bytes and char occupies one byte, the size of bytes sent is 4 + 1*4 = 8 byte[] request = new byte[8]; //Convert int type channel data to byte and copy the data to the request array byte[] channelBytes = Packet.intToByteArray_Little(channel); System.arraycopy(channelBytes, 0, request, 0, 4); //Send the encapsulated byte[] data to the device through the API camera.TK_sendIOCtrlToChannel(Camera.DEFAULT_AV_CHANNEL, IOTYPE_GET_LED_REQ, request);</code></pre> <h2>3.3 Receive the data replied by the device through callback and parse it</h2> <pre><code class="language-java">camera.TK_registerIOTCListener(new InterfaceCtrl.SimpleIOTCListener() { @Override public void receiveIOCtrlData(Camera camera, int avChannel, int avIOCtrlMsgType, byte[] data) { if (avIOCtrlMsgType == IOTYPE_GET_LED_RESP) { //In the structure SMsgAVIoctrlGetLedResp, because int occupies 4 bytes and char occupies one byte, the size of bytes received is 4 + 1 + 1*3 = 8 //Among them, the first 4 bytes represent the result information returned by the device, the fifth byte represents the isOnOff information returned by the device, and the last three bytes represent reserved bits that do not need to be parsed. //1、Parse result information int result = Packet.byteArrayToInt(data, 0); //2、Parse isOnOff information int isOnOff = (int)data[4]; } } });</code></pre> <h2>3.4 byte[] data type conversion API</h2> <pre><code class="language-java">Referring to the AVIOCTRLDEF module of Android Psc, the com.tutk.IOTC.Packet class contains various data conversion APIs</code></pre> <h1>4、VideoMonitor(player)</h1> <h2>4.1 Method</h2> <h3>TK_attachCamera</h3> <pre><code class="language-java">/** * Bind the Camera instance to the player * * @param camera Camera instanse * @param avChannel generally 0 */ public void TK_attachCamera(Camera camera, int avChannel)</code></pre> <pre><code class="language-java">Example: videoMonitor.TK_attachCamera(camera, Camera.DEFAULT_AV_CHANNEL);</code></pre> <h3>TK_deattachCamera</h3> <pre><code class="language-java">/** * playe detach Camera */ public void TK_deattachCamera()</code></pre> <pre><code class="language-java">Example: videoMonitor.TK_deattachCamera();</code></pre> <h3>setScaleType</h3> <pre><code class="language-java">/** * Select the automatic scaling method of the control. The default is SCALE_ASPECT * * @see ScaleType#SCALE_ASPECT,Video footage maintains aspect ratio * @see ScaleType#SCALE_ASPECT_FILL,Video screen fills the screen */ public void setScaleType(ScaleType scaleType)</code></pre> <pre><code class="language-java">Example: videoMonitor.setScaleType(ScaleType.SCALE_ASPECT);</code></pre> <h2>4.2 callback interface</h2> <h3>TK_setMonitorListener</h3> <pre><code class="language-java">/** * Player status monitoring */ public void TK_setMonitorListener(InterfaceCtrl.MonitorListener listener)</code></pre> <pre><code class="language-java">public interface MonitorListener { /** * Player click event */ void onClick(); /** * The player is ready to render pictures * * @param channel generally 0 * @param isSoftwareDecode whether software decode or not */ void onReady(int channel, boolean isSoftwareDecode); /** * The player zoom multiple is passed to the UI layer * * @param scaleLevel Zoom multiple */ void onScale(float scaleLevel); }</code></pre> <pre><code class="language-java">Example: videoMonitor.TK_setMonitorListener(new InterfaceCtrl.SimpleMonitorListener());</code></pre> <h1>5、connect Demo</h1> <p>layout code</p> <pre><code class="language-java">&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt; &amp;lt;androidx.constraintlayout.widget.ConstraintLayout xmlns:android=&amp;quot;http://schemas.android.com/apk/res/android&amp;quot; android:layout_width=&amp;quot;match_parent&amp;quot; android:layout_height=&amp;quot;match_parent&amp;quot;&amp;gt; &amp;lt;com.tutk.IOTC.VideoMonitor android:id=&amp;quot;@+id/videoMonitor&amp;quot; android:layout_width=&amp;quot;match_parent&amp;quot; android:layout_height=&amp;quot;match_parent&amp;quot; /&amp;gt; &amp;lt;/androidx.constraintlayout.widget.ConstraintLayout&amp;gt;</code></pre> <p>java code</p> <pre><code class="language-java">public class TestActivity extends Activity { private final Camera camera = new Camera(); private VideoMonitor videoMonitor; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_test); //bind camera videoMonitor = (VideoMonitor) findViewById(R.id.videoMonitor); videoMonitor.TK_attachCamera(camera, Camera.DEFAULT_AV_CHANNEL); //IOTC initial Camera.TK_initIOTC(this, privateKey, sdkLicenseKey, new TK_Listener() { @Override public void success() { //connect Device camera.TK_connect(uid); camera.TK_registerIOTCListener(mListener); } @Override public void failure(int Error) { } @Override public void doInBackground() { } }); } @Override protected void onDestroy() { super.onDestroy(); //unbind videoMonitor.TK_deattachCamera(); //remove callback camera.TK_unregisterIOTCListener(mListener); //disconnect camera.TK_disconnect(); //unintial Camera.TK_unInitIOTC(); } private final InterfaceCtrl.IOTCListener mListener = new InterfaceCtrl.SimpleIOTCListener() { @Override public void receiveSessionInfo(Camera camera, int resultCode) { if (resultCode == Camera.CONNECTION_STATE_CONNECTED) { //connect av channel camera.TK_start(Camera.DEFAULT_AV_CHANNEL, password); } } @Override public void receiveChannelInfo(Camera camera, int avChannel, int resultCode) { if (resultCode == Camera.CONNECTION_STATE_CONNECTED) { //start video stream camera.TK_startShow(Camera.DEFAULT_AV_CHANNEL); } } }; }</code></pre>

页面列表

ITEM_HTML