中文简体    English


Description

Initializing SDK, you must call this api once before using other api

void init()

Parameters

None

Return value

None

Remarks

The discovery device thread will start when initialize SDK


Description

Get SDK Version

String version()

Parameters

None

Return value

SDK Version

Remarks

Size of buffer should be more than 32 bytes


Description

Log setting

void setLog(int level, String path, int maxSize)

Parameters

iLevel log level
path save file path
maxSize Max size of log file, unit is MB

Reference

package com.ivyio.sdk;

public class LogLevel {
    public static final int NO = 0; // nothing output
    public static final int ERR = 1; // only error
    public static final int DBG = 2; // only debug
    public static final int ALL = 3; // all
}

Return value

None

Remarks

SDK will output all logs as default, Logs don’t save if szPath is NULL or length is zero; iMaxSize can be zero, it means use default value 5MB


Description

Discovery devices

int discovery(DiscoveryNode[] nodes, int countOfNode)

Parameters

nodes Array of IVYIO_DEV_NODE type
countOfNode Count of IVYIO_DEV_NODE array

Return value

Actually searched count

Remarks

None

Reference

package com.ivyio.sdk;

public class DiscoveryNode {
    public int version;
    public int type;
    public String ip;
    public String mask;
    public String dns;
    public int port;
    public String mac;
    public String uid;
    public String name;
}

Description

Restart discovery device

void restartDiscovery()

Parameters

None

Return value

None

Remarks

None


Description

Stop discovery device

void stopDiscovery()

Parameters

None

Return value

None

Remarks

If you stop searching for the device, the SDK will not be able to discover the device through the search protocol. At this time, if the device and the application are in the same LAN, you cannot use the LAN to connect to the device.


Description

Get thread of discovery state

int getDiscoveryState()

Parameters

None

Return value

State of discovery

0 discovery in process
1 discovery stoped

Remarks

None


Description

Create SDK handle

int create(Url url, String uid, String mac, String user, String password, int mode)

Parameters

url IVY_URL object, it contains device address and port;Device address can be DDNS or IP
uid Device’s UID
mac Device’s mac
user Device’s username
password Device’s password
mode P2P connection mode 0:UDP 1:TCP 2:AUTO

Return value

SDK handle, the handle value is increasing number, handle value still increasing even if you call destroy api

Remarks

If parameter mode is UDP mode, P2P component will use UDP mode;If parameter mode is TCP mode, P2P component will use TCP mode;If parameter mode is AUTO mode, P2P will use UDP and TCP ways alternately.
SDK search device in LAN at first(via match UID or IP, first is UID, second is IP) when SDK connecting, if SDK found device, connect device by IP.

Device is in WLAN, SDK has different operations:

  1. URL and UID are not empty, SDK connect by uid first, if connect failed using IP to connect.
  2. Only UID, SDK connect by UID only.
  3. Only URL, SDK connect by URL only.

Reference

package com.ivyio.sdk;

public class Url {
    public String url;
    public int port;
}


public class P2PMode {
    public static final int P2P_MODE_UDP = 0;
    public static final int P2P_MODE_TCP = 1;
    public static final int P2P_MODE_AUTO = 2;
}

Description

Release resource

void destroy(int handle)

Parameters

handle SDK handle

Return value

None

Remarks

Call this api the handle instance’s memory will be released. Please don’t call api with same handle in different thread, SDK can’t handle and will crash.
For can call api parallel, SDK can’t keep safe when handle are same, but call api with different handle in different thread is safe.


Description

Get device state

int checkHandle(int handle);

Parameters

handle SDK handle

Return value

Device state

0 Initialization
1 Connecting
2 Online
3 Offline
4 Max user number
5 Lock
6 Username or password error
7 Access deny
8 Unknown
9 Invalid handle
10 User cancel operation

Remarks

None

Reference

package com.ivyio.sdk;

public class HandleState {
    public static final int HANDLE_STATE_INIT = 0;
    public static final int HANDLE_STATE_CONNECTTING = 1;
    public static final int HANDLE_STATE_ONLINE = 2;
    public static final int HANDLE_STATE_OFFLINE = 3;
    public static final int HANDLE_STATE_MAX_USERS = 4;
    public static final int HANDLE_STATE_LOCK = 5;
    public static final int HANDLE_STATE_USR_OR_PWD_ERR = 6;
    public static final int HANDLE_STATE_DENY = 7;
    public static final int HANDLE_STATE_UNKNOWN = 8;
    public static final int HANDLE_STATE_INVALID_HANDLE = 9;
    public static final int HANDLE_STATE_CANCEL_BY_USR = 10;
}

Description

Login device

int login(int handle, int timeout)

Parameters

handle SDK handle
timeout timeout, unit ms

Return value

Operation code

0 Success
1 Fail
2 Invalid handle
3 Username or password error
4 Parameter error
5 Api runtime error
6 Access deny
7 Locked
8 Max user
9 Talk opened by other
10 User cancel operation
11 Timeout
12 Unsupport
13 Unknow
14 Offline

Remarks

None

Reference

package com.ivyio.sdk;

public class Result {
    public static final int OK = 0;
    public static final int FAIL = 1;
    public static final int HANDLE_ERR = 2;
    public static final int USR_OR_PWD_ERR = 3;
    public static final int ARGS_ERR = 4;
    public static final int APITIME_ERR = 5;
    public static final int DENY = 6;
    public static final int LOCKED = 7;
    public static final int MAX_USER = 8;
    public static final int TALK_OPENED_BY_OTHERS = 9;
    public static final int CANCEL_BY_USER = 10;
    public static final int TIMEOUT = 11;
    public static final int UNSUPPORT = 12;
    public static final int UNKNOWN = 13;
    public static final int OFFLINE = 14;
}

Description

Logout

void logout(int handle)

Parameters

handle SDK handle

Return value

None

Remarks

Call this api all connection will disconnect, instance is still exist, this handle is still valid and you can continue to use.


Description

Open video

int openVideo(int handle, OpenVideoArgs args, int timeout, int channel)

Parameters

handle SDK handle
args OpenVideoArgsType0 objcet, object member streamType indicate stream format, 0:main stream, 1:sub stream
timeout Timeout, unit ms
channel Channel number, you can open multiple device, (bit0-bit31 indicate channel0 - channel31), for example, 0x06 indicate open channel 1 and channel2

Return value

Operation code

Remarks

This api support multiple device. SDK will allocate some memories for video/audio/decoder when you call it, you call close video api SDK will release video/audio/decoder memory. The media transimit channel is created when open video, but this channel don’t close when call close video.

Reference

package com.ivyio.sdk;

public class OpenVideoArgsType0 extends OpenVideoArgs{
    public OpenVideoArgsType0() {
        argsType = 0;
    }

    public int streamType;

}

Description

Close video

int closeVideo(int handle, int timeout, int channel)

Parameters

handle SDK handle
timeout Timeout, unit ms
channel Channel No., same as open video

Return value

Operation code

Remarks

If device is IPC, iChannel reference OpenVideo, iChannel of CloseVideo api must be same as iChannel of OpenVideo api, or else memory leak.


Description

Open audio

int openAudio(int handle, int audioStreamtype, int timeout, int channel)

Parameters

handle SDK handle
audioStreamtype audio type, 0:main 1:sub
timeout Timeout, unit ms
channel Channel NO, same as openVideo

Return value

Operation code

Remarks

You must open video first before open audio, the media channel is create when open video, so you also can’t open audio if close video, the video/audio memory is free when close video.


Description

Close audio

int closeAudio(int handle, int timeout, int channel)

Parameters

handle SDK handle
timeout Timeout, unit ms
channel Channel No, same as open video

Return value

Operation code

Remarks

None


Description

Get playback list

int getPlaybackRecordList(int handle, GetPlaybackListArgs args, PlaybackRecordListArgs list, int timeout, int channel)

Parameters

handle SDK handle
args Instance of GetPlaybackListArgs object
list Instance of PlaybackRecordListArgs object
timeout Timeout, unit ms
channel Channel No, same as open video

Return value

Operation code

Remarks

args / list paramters:

args GetPlaybackListArgsType0
list PlaybackRecordListArgsArrayType0

If device is IPC, channel value reference openVideo

Reference

package com.ivyio.sdk;

public class GetPlaybackListArgsType0  extends GetPlaybackListArgs {
    public GetPlaybackListArgsType0() {
        argsType = 0;
    }

    public long sTime; 
    public long eTime; 
    public int type; 
    public int startNo; 
    public int cnt; 
}

public class PlaybackRecordListArgsArrayType0 extends PlaybackRecordListArgs {
    public PlaybackRecordListArgsArrayType0() {
        playbackListArgsType = 0;
    }

    public PlaybackRecordListArgsType0[] list;
}

public class PlaybackRecordListArgsType0 {

    public int totalCnt; 
    public int curCnt;
    public PlaybackRecordListInfoArgsType0[] list;
}

public class PlaybackRecordListInfoArgsType0 {
    public int channel; 
    public long sTime; 
    public long eTime; 
    public int recordType; 
}


Description

Open playback

int openPlayback(int handle, OpenPlaybackArgs args, int timeout, int channel)

Parameters

handle SDK handle
args OpenPlaybackArgs object instance
timeout Timeout, unit is ms
channel Channel No, same as open video

Return value

Operation code

Remarks

SDK deal with video/audio memory same as live.

paramters object:

args OpenPlaybackArgsType0

If device is IPC, channel value reference openVideo

Reference

package com.ivyio.sdk;

public class OpenPlaybackArgsType0  extends OpenPlaybackArgs {

    public OpenPlaybackArgsType0(){
        argsType = 0;
    }

    public long sTime;
    public long eTime;
    public int streamType;

}

Description

Close playback

int closePlayback(int handle, ClosePlaybackArgs args, int timeout, int channel)

Parameters

handle SDK handle
args ClosePlaybackArgs object instance
timeout Timeout, unit is ms
channel Channel No

Return value

Operation value

Remarks

args ClosePlaybackArgsType0

If device is IPC, channel value is same as openPlayback

Reference

package com.ivyio.sdk;

public class ClosePlaybackArgs {
    public int argsType;
}

public class ClosePlaybackArgsType0  extends ClosePlaybackArgs {
    public ClosePlaybackArgsType0(){
        argsType = 0;
    }
}

Description

Playback pause

int playbackPause(int handle, PlaybackPauseArgs args, int timeout)

Parameters

handle SDK handle
args PlaybackPauseArgs object instance
timeout Timeout, unit is ms

Return value

Operation code

Remarks

args PlaybackPauseArgsType0

Reference

package com.ivyio.sdk;

public class PlaybackPauseArgs {
    public int argsType;
}


public class PlaybackPauseArgsType0 extends PlaybackPauseArgs{
    public PlaybackPauseArgsType0() {
        argsType = 0;
    }
}


}

Description

Playback resume

int playbackResume(int handle, PlaybackResumeArgs args,  int timeout)

Parameters

handle SDK handle
args PlaybackResumeArgs object instance
timeout Timeout, unit is ms

Return value

Operation code

Remarks

args PlaybackResumeArgsType0

Reference

package com.ivyio.sdk;

public class PlaybackResumeArgs {
    public int argsType;
}

public class PlaybackResumeArgsType0 extends PlaybackResumeArgs {
    public PlaybackResumeArgsType0() {
        argsType = 0;
    }
}


Description

Playback seek

int playbackSeek(int handle, PlaybackSeekArgs args, int timeout, int channel)

Parameters

handle SDK handle
args PlaybackSeekArgs object instance
timeout Timeout, unit is ms
channel Channel No 0-31, only operation one channel, open 0 channel, iChannel is 0, open 1 channel, iChannel is 1

Return value

Operation code

Remarks

args PlaybackSeekArgsType0

Reference

package com.ivyio.sdk;

public class PlaybackSeekArgs {
    public int argsType;
}


public class PlaybackSeekArgsType0 extends PlaybackSeekArgs {
    public PlaybackSeekArgsType0() {
        argsType = 0;
    }

    public long seekTime; // JG unit is s, Thor unit is ms
}

Remarks

If device is NVR, seek need channel paramter


Description

Open talk

int openTalk(int handle, int timeout, int channel)

Parameters

handle SDK handle
timeout Timeout, unit is ms
channel Channel No 0-31, only operation one channel, open 0 channel, iChannel is 0, open 1 channel, iChannel is 1

Return value

Operation code

Remarks

None


Description

Close talk

int closeTalk(int handle, int timeout, int channel)

Parameters

handle SDK handle
timeout Timeout, unit is ms
channel The same as open talk

Return value

Operation code

Remarks

None


Description

Send talk data to device

int sendTalkData(int handle, byte[] data, int sizeOfData, int channel)

Parameters

handle SDK handle
data take data
sizeOfData Data size
channel Same as open talk

Return value

Operation code

Remarks

Data format supoort PCM only


Description

Get stream

int getStreamData(int handle, int streamType, FrameData data, Integer speed, int decodeFormat, int channel)

Parameters

handle SDK handle
streamType stream type 0:video 1:audio
data FrameData object
speed Media streaming speed
decodeFormat Decoder type IVYIO_DECODE_FMT , you can ignore it if stream is audio
channel Channel No 0-31, one time get one channel data only

Return value

Operation code

Remarks

The memory of stream data is manage by SDK, SDK allocate and free.If call close vido api that memory will be free, so caller must be keep IVYIO_FRAME pointer is not used by application, or else may crash.
(You should make play media thread quit before call close video)

// Sample 1
// Channel 1
IvyIoSdkJni.openVideo(..., 2);
IvyIoSdkJni.getStreamData(..., 1);
IvyIoSdkJni.closeVideo(..., 2);

// Sample 2
// Channel 0
IvyIoSdkJni.openVideo(..., 1);
IvyIoSdkJni.getStreamData(..., 0);
IvyIoSdkJni.closeVideo(..., 1);

// Sample 3
// Channel 3
IvyIoSdkJni.openVideo(..., 8);
IvyIoSdkJni.getStreamData(..., 3);
IvyIoSdkJni.closeVideo(..., 8);

Reference

package com.ivyio.sdk;

public class FrameData {
    public int channel;
    public int index;
    public int key;
    public int frameTag;
    public long pts;
    public int type;
    public int fmt;
    public int video_w;
    public int video_h;
    public int video_frameRate;
    public int video_bitRate;
    public int audio_bitPerSample;
    public int audio_channels;
    public int audio_samples;
    public int dataLen;
    public byte[] data;
}

package com.ivyio.sdk;

public class DecodeFormat {
    public static final int VIDEORAW = 0;
    public static final int ARGB32 = 1;      //packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
    public static final int RGBA32 = 2;    //packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
    public static final int ABGR32 = 3;    //packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
    public static final int BGRA32 = 4;    //packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
    public static final int RGB24 = 5;      //packed RGB 8:8:8, 24bpp, RGBRGB...
    public static final int BGR24 = 6;     //packed RGB 8:8:8, 24bpp, BGRBGR...
    public static final int RGB565BE = 7;  //packed RGB 5:6:5, 16bpp, (msb)   5R 6G 5B(lsb), big-endian
    public static final int RGB565LE = 8;  //packed RGB 5:6:5, 16bpp, (msb)   5R 6G 5B(lsb), little-endian
    public static final int BGR565BE = 9;  //packed BGR 5:6:5, 16bpp, (msb)   5B 6G 5R(lsb), big-endian
    public static final int BGR565LE = 10;  //packed BGR 5:6:5, 16bpp, (msb)   5B 6G 5R(lsb), little-endian

    public static final int YUV420 = 11;
    public static final int YUYV422 = 12;
    public static final int UYVY422 = 13;
    public static final int H264 = 14;
    public static final int MJPEG = 15;    
    public static final int MJPEG_BASE64 = 16;
    public static final int H264_BASE64 = 17;

    public static final int AUDIORAW = 18;
    public static final int G726 = 19;
    public static final int G711U = 20;
    public static final int PCM = 21;
    public static final int ADPCM = 22;
    public static final int G711A = 23;
    public static final int AAC = 24;

    public static final int HEVC = 25;
}

Description

Get raw stream data

int getRawStreamData(int handle, int streamType, FrameData data, Integer speed, int channel)

Parameters

handle SDK handle
streamType stream type 0:video 1:audio
data FrameData object
speed Media streaming speed
channel Channel No 0-31, one time get one channel data only

Return value

Operation code

Remarks

This api get raw stream data, H264 / H265 / pcm. Attention is same as IVYIO_GetStreamData

Reference

package com.ivyio.sdk;

public class FrameData {
    public int channel;
    public int index;
    public int key;
    public int frameTag;
    public long pts;
    public int type;
    public int fmt;
    public int video_w;
    public int video_h;
    public int video_frameRate;
    public int video_bitRate;
    public int audio_bitPerSample;
    public int audio_channels;
    public int audio_samples;
    public int dataLen;
    public byte[] data;
}

Description

Get playback stream data

int getPlaybackStreamData(int handle, int streamType, FrameData data, Integer speed, int decodeFormat, int channel)

Parameters

handle SDK handle
streamType stream data 0:video 1:audio
data FrameData object
speed Media streaming speed
decodeFormat Decoder type IVYIO_DECODE_FMT , ignore this param if stream is audio
channel Channel No 0-31, one time get one channel data only

Return value

Operation code

Remarks

Attention same as IVYIO_GetStreamData。If current device is NVR, you may want to know detail information of frame, you can got it from iFrameTag. FRAME_TAG_PLAYBACK_E_FRAME tell you this frame is the last one, and data can be ignored.

Reference

package com.ivyio.sdk;

public class FrameTag {
    // live video / audio frame 
    public static final int LIVE_FRAME = 0x4556494c;
    // Playback video / audio frame
    public static final int PLAYBACK_FRAME = 0x4b424c50;
    // The last frame of playback
    public static final int PLAYBACK_E_FRAME = 0x46454250;

}

Description

Get playback raw stream data

int getPlaybackRawStreamData(int handle ,int streamType, FrameData data, Integer speed, int channel)

Parameters

handle SDK handle
streamType stream type 0:video 1:audio
data FrameData object
speed Media streaming speed
channel Channel No 0-31, one time get one channel data only

Return value

Operation code

Remarks

Attention same as IVYIO_GetRawStreamData。IVYIO_FRAME’s filed iFrameTag reference IVYIO_GetPlaybackStreamData


Description

Start record

int startRecord(int handle, int recordType, String fileName, int maxSize, int channel)

Parameters

handle SDK handle
recordType record type 1:MP4
fileName Record full file path name
maxSize Max size of record file, 0 means using default 256M, unit is MB
channel Channel No 0-31, one time get one channel data only

Return value

Operation code

Remarks

If record file size arrive max size, SDK will generate a event, you can get it, if resolution changed, also generate a event.

2052 No enough space
2053 File max size
2054 Resolution changed
2055 Path is not exist
2056 Unknown error

Reference

package com.ivyio.sdk;

public class RecordType {
    public static final int AVI = 0;
    public static final int MP4 = 1;
}

Description

Stop record

int stopRecord(int handle, int channel)

Parameters

handle SDK handle
channel Channel No 0-31, one time get one channel data only

Return value

Operation code

Remarks

None


Description

Send command

int sendCommand(int handle, int cmd, String cmdData, Response respone, int timeout)

Parameters

handle SDK handle
cmd Command ID
cmdData Command string
response Response string
timeout Timeout, unit is ms

Return value

Operation code

Remarks

cmd id range is 22019-42018, this cmd defined by developer, SDK only transimit data and don’t handle it, command data struct defined by application and embedded system;
If it is not android app, you need focus on iSizeOfResponse value, data is encrypted, if response is a Json string, you don’t use iSizeOfResponse, response may contains some “\0”, should call strlen(response), you will get actual string length, or else you Json parser component may parse failed(iOS has this problem).If response is binary data, use iSizeOfResponse is ok.

Reference

package com.ivyio.sdk;

public class CmdReturnCode {
    public static final int SUCCESS = 0; // success
    public static final int FAIL = -1; // fail
    public static final int ERR_ARGS = -2; // err args
    public static final int UNSUPPORT = -9; // unsupport 
    public static final int FORMAT_UNSUPPORT = -15; // unsupport
}

Description

Get event

int getEvent(int handle, Event event)

Parameters

handle SDK handle
Event Event object

Return value

Operation code

Remarks

The scope of event id is 42019-65535 as usually, this scape defined by developer, similar to api IVYIO_SendCommand, SDK only transmit data but don’t parse any data, command id usage and struct defined by app and embed. Some events is generate by SDK, and this events isn’t belong to scope 42019-65535.

Reference

package com.ivyio.sdk;

public class Event {
    public int id;
    public String data;
}

Description

Get live stream, stream format is YUV420P

int getStreamYUV420P(int handle, byte[] y, byte[] u, byte[] v, Integer w, Integer h, Integer key, Integer bitRate, Integer frameRate, Integer speed, int channel);

Parameters

handle SDK handle
y y data
u u data
v v data
w width
h height
key I frame 0: not I frame 1:I frame
bitRate Bit rate
frameRate Frame rate
speed Value of media flow value
channel Channel No 0-31, one time get one channel data only

Return value

Operation code

Remarks

The data size of y / u / v can be calculated (refer to YUV420P format), the line size has been processed by the JNI layer, and yuv is already the actual data.


Description

Get playback stream, stream format is YUV420P

int getPlaybackStreamYUV420P(int handle, byte[] y, byte[] u, byte[] v, Integer w, Integer h, Integer key, Integer bitRate, Integer frameRate, Integer index, Integer frameTag, Long pts, int channel)

Parameters

handle SDK handle
y y data
u u data
v v data
w width
h height
key I frame 0: not I frame 1:I frame
bitRate Bit rate
frameRate Frame rate
index Index
frameTag tag information
pts Timestamp
channel Channel No 0-31, one time get one channel data only

Return value

Operation code

Remarks

The data size of y / u / v can be calculated (refer to YUV420P format), the line size has been processed by the JNI layer, and yuv is already the actual data.


Description

Setting CPU count for FFmpeg

int setCPUCount(int handle, int count);

Parameters

handle SDK handle
count cpu count

Return value

Operation code

Remarks

As default if don’t call this api SDK will set FFmpeg use 1 thread to decode. IF you call this api, FFmpeg will use thread count that you set to decode. Please fill in the actual number of CPUs as much as possible. Threads equal to the number of CPUs may speed up decoding. Determine whether to call this interface based on actual results.


Description

Convert key frame to a picture

int keyFrame2Picture(int handle, byte[] inData, byte[] outData, Integer lenOfOutData, int channel);

Parameters

handle SDK handle
inData Input data buffer
outData Output data buffer
iLenOfOutData outData buffer size
channel Channel NO.

Return value

Operation code

Remarks

lenOfOutData, as the input parameter indicates the size of the outData buffer, and as the output indicates the actual output buffer size; if the input parameter size is smaller than the actual required buffer size, the function returns an error, but as the output lenOfOutData will tell the actual required buffer size.


Description

Download record

int downloadRecord(int handle, DownloadRecord record, String dstPath, int timeout)

Parameters

handle SDK handle
record DownloadRecord objcet, You can get parameters via search record api
dstPath Save path, none inclue file name, SDK generate a filename auto
timeout timeout

Return value

Operation code

Remarks

Only one video can be downloaded at a time, not in parallel. If the current video is not downloaded complete, the interface returns
IVYIO_RESULT_DOWNLOADING (17), download progress event IVY_CTRL_MSG_RECORD_DOWNLOAD_PROGRESS (2063). The device disconnect the download connection every time it sends recording data complete, so every downloading needs to call the download interface once. Because the SDK will connect every time it is called.


Description

Cancel record download

void downloadRecordCancel(int handle)

Parameters

handle SDK handle

Return value

None

Remarks

The cancel download video SDK did not send any command to the device, but just disconnected the download connection. When the download interface is called again, the SDK will connect to the download channel again.


文档更新时间: 2024-01-11 18:11   作者:庄小婵