中文简体 English
- C/C++ interface documentation, suitable for macOS / Windows
- 1. Initialization
- 1.1 Initialize device
- 2. SDK version number and log system
- 2.1 SDK version number
- 2.2 Set log level and path
- 3. Device search
- 3.1 Search for devices in the LAN
- 3.2 Restart device search
- 3.3 Stop searching for devices
- 3.3 Get the current search status
- 4. Log in to the device
- 4.1 Create SDK handle (1) (IVY devices recommend using this interface)
- 4.1.1 Create SDK handle (3) (IVY low-power devices must use this interface)
- 4.2 Create SDK handle (2) (Foscam devices recommend using this interface)
- 4.3 Destroy SDK handle
- 4.4 Detect the status of the device corresponding to the current handle
- 4.5 Log in to the device
- 4.6 Log out of the device
- 4.7 Obtain the TURN server information of the P2P connection after successful login
- 4.8 Specify P2P turn server
- 4.9 Specify FoscamP2P connection dispatch server area
- 5. Device live streaming
- 5.1 Open live video
- 5.2 Close live video
- 5.3 Turn on live audio
- 5.4 Turn off live audio
- 5.5 Start live recording
- 5.6 Stop live recording
- 6. Talkback
- 6.1 Open intercom
- 6.2 Turn off intercom
- 6.3 Send intercom data
- 7. Device playback
- 7.1 Get the recording list of the device
- 7.2 Open playback
- 7.3 Close playback
- 7.4 Playback Control
- 7.5 Start playback video download (IVY device)
- 7.6 Cancel playback video download (IVY device)
- 7.7 Start playback video download (FosamIPC)
- 7.8 Cancel playback video download (FosamIPC)
- 7.9 Start playback video download (FosamNVR)
- 7.10 Cancel playback video download (FosamNVR)
- 8. Get live/playback video and audio data
- 8.1 Obtain the decoded data of the live broadcast
- 8.2 Obtain the original audio and video data of the live broadcast
- 8.3 Obtain playback of decoded audio and video data
- 8.4 Obtain and playback original audio and video data
- 8.5 Decode and playback video data
- 9. Send command
- 9.1 Send command (recommended)
- 9.2 Send CGI
- 10. Auxiliary interface
- 10.1 Get events
- 10.1.1 Get event 2
- 10.2 Convert keyframes into a picture
- 10.3 Query SDK interface calling status
- 11. Doorbell answering interface
- Interface applicable scope
- 11.1 Create doorbell device handle and log in
- 11.2 Turn on doorbell video
- 11.3 Turn off doorbell video
- 11.4 Turn on doorbell audio
- 11.5 Turn off doorbell audio
- 11.6 Turn on doorbell intercom
- 11.7 Turn off the doorbell intercom
- 11.8 Send intercom data to the doorbell
- 11.9 Get doorbell data (decoded)
- 11.10 Get doorbell data (not decoded)
- 11.11 Doorbell local recording starts
- 11.12 Doorbell local recording ends
- 11.13 Detect doorbell handle status
- 11.14 Get doorbell events
- 11.15 Set OpenTalk intercom flag (only applicable on iOS platform)
- 11.16 Doorbell answering status query
- 12 Get image interface (only supports IVY devices)
- 12.1 Get image list
- 12.2 Get image data
- 13. RTSP API (non-thread safe)
- 13.1 Turn on RTSP
- 13.2 Turn off RTSP
- 13.3 Get RTSP stream (original video + PCM audio)
- 13.4 Get RTSP stream (decoded video + PCM audio)
- 14. Two-way video
- 14.1 Turn on two-way video
- 14.2 Turn off two-way video
- 14.3 Send video
- 14.4 Send audio
- 14.5 Reject Video
- 14.6 Get two-way video status
C/C++ interface documentation, suitable for macOS / Windows
1. Initialization
1.1 Initialize device
- describe
Initialize the SDK and must call it once before using the SDK.
void IVYIO_API IVYIO_Init()
- Parameters
none
- return value
none
- Remark
During initialization, the SDK will start the search thread, initialize P2P, and start the internal clock thread.
- Call example
IVYIO_Init();
2. SDK version number and log system
2.1 SDK version number
- describe
Get SDK version number
void IVYIO_API IVYIO_Version(char *szVer)
- Parameters
szVer | buffer |
---|
- return value
none
- Remark
It is recommended that the buffer for storing the version number be at least larger than 32 bytes.
- Call example
char szVersion[64] = {0};
IVYIO_Version(szVersion);
2.2 Set log level and path
- describe
Set log printing and log sectors
void IVYIO_API IVYIO_SetLog(int iLevel, char *szPath, int iMaxSize)
- Parameters
iLevel | Log level |
---|---|
szPath | Save file path |
iMaxSize | The maximum size of the log file, in M |
iLevel level
0 | IVYIO_LOG_LEVEL_NO | Do not output logs |
---|---|---|
1 | IVYIO_LOG_LEVEL_ERR | Output errors only |
2 | IVYIO_LOG_LEVEL_DBG | Output debug only |
3 | IVYIO_LOG_LEVEL_ALL | Output all |
- return value
none
- Remark
The default log level of the SDK is all output. If szPath is NULL or the length is 0, no log will be written to the specified path; iMaxSize can be 0, which means the default size of 5M is used.
- Call example
#ifdef _WIN32
char szPath[MAX_PATH] = "d:\\sdklog\\sdk.log";
#else
char szPath[512] = "/sdklog/sdk.log";
#endif
IVYIO_SetLog(IVYIO_LOG_LEVEL_ALL, szPath, 0);
3. Device search
3.1 Search for devices in the LAN
- *describe
Search for devices in LAN
void IVYIO_API IVYIO_Discovery(IVYIO_DEV_NODE *nodes, int *iCountOfNode)
- Parameters
nodes | IVYIO_DEV_NODE type array that stores device nodes |
---|---|
iCountOfNode | The number of device nodes, as input, is the number of elements in the nodes array, as output, it represents the actual number searched |
- return value
none
- Remark
none
- Call example
IVYIO_DEV_NODE nodes[32] = {0};
memset(nodes, 0, sizeof(nodes));
int count = sizeof(nodes) / sizeof(IVYIO_DEV_NODE);
IVYIO_Discovery(nodes, &count);
if (count > 0)
{
...
}
3.2 Restart device search
- describe
Restart device search
void IVYIO_API IVYIO_RestartDiscovery()
- Parameters
none
- return value
none
- Remark
none
- Call example
IVYIO_RestartDiscovery();
3.3 Stop searching for devices
- describe
Stop device search
void IVYIO_API IVYIO_StopDiscovery()
- Parameters
none
- return value
none
- Remark
After stopping the search, the SDK will use P2P to connect.
- Call example
IVYIO_StopDiscovery();
3.3 Get the current search status
- describe
Get the status of current device search
int IVYIO_API IVYIO_GetDiscoveryState()
- Parameters
none
- return value
SDK current device search status
0 | Device search running |
---|---|
1 | Device search has stopped |
- Remark
none
- Call example
int state = IVYIO_GetDiscoveryState();
if (0 == state)
{
...
}
else if (1 == state)
{
...
}
else
{
...
}
4. Log in to the device
4.1 Create SDK handle (1) (IVY devices recommend using this interface)
- describe
Create SDK instance handle
IVYIO_HANDLE IVYIO_API IVYIO_Create(IVY_URL *url, char *szUid, char *szUser, char *szPassword, IVYIO_P2P_MODE mode)
- Parameters
url | Structure that stores the connection address and port of the target device; the address can be DDNS or IP |
---|---|
szUid | UID of the target device, can be empty |
szUser | The user name of the target device, cannot be empty |
szPassword | The password of the target device, cannot be empty |
mode | P2P connection mode 0: UDP mode 1: TCP mode 2: Automatic |
- return value
SDK handle, which is incremented when returning the handle, and will also be incremented after it is created after it is released.
- Remark
If the mode uses UDP mode, the internal P2P connection will use UDP mode; if TCP mode is used, the P2P connection will use TCP connection. If AUTO mode is used, the SDK will automatically switch internally, once to UDP mode and once to TCP mode.
If you do not manually stop the device search, the SDK will first search the LAN for the device you are connected to when connecting (matching by UID or IP, UID first, then IP), if found, it will go directly to the LAN, so, If your UID is correct, you can connect if the IP address and port are wrong.
When the device is not in the LAN, the SDK connection will behave differently depending on the parameters:
- URL and UID exist at the same time. The SDK first uses UID to connect. If the connection fails, it uses IP to connect.
- Only UID, the SDK will only use UID to connect.
- Only URL, SDK will only use URL to connect.
- Quote
typedef struct _IVYIO_URL_
{
char szUrl[256]; // IP or DDNS
unsigned short usPort; // IP or IP corresponding to DDNS
}ATTRIBUTE_PACKED IVYIO_URL, *PIVYIO_URL;
- Call example
IVYIO_URL url;
memset(&url, 0, sizeof(url));
strcpy(url.szUrl, "192.168.1.1");
url.usPort = 88;
IVYIO_HANDLE handle = IVYIO_Create(&url, "ABCDABCDABCDABCDABCD2222", "username", "password", IVYIO_P2P_MODE_UDP);
4.1.1 Create SDK handle (3) (IVY low-power devices must use this interface)
- describe
Create an SDK instance handle. If lowPower is 0, the interface functions and usage methods are exactly the same as IVYIO_Create.
IVYIO_HANDLE IVYIO_API IVYIO_Create_1(IVY_URL *url, char *szUid, char *szUser, char *szPassword, IVYIO_P2P_MODE mode, int lowPower)
- Parameters
url | Structure that stores the connection address and port of the target device; the address can be DDNS or IP |
---|---|
szUid | UID of the target device, can be empty |
szUser | The user name of the target device, cannot be empty |
szPassword | The password of the target device, cannot be empty |
mode | P2P connection mode 0: UDP mode 1: TCP mode 2: Automatic |
lowPower | Whether it is a low-power device 0: Same behavior as IVYIO_Create 1: Indicates that the current device is a low-power device. The SDK will start an interface call timer internally. If the SDK interface is not called after the specified time, the SDK can tell the application that the application can Query by IVYIO_ApiCallTimeIsUp |
- return value
SDK handle, which is incremented when returning the handle, and will also be incremented after it is created after it is released.
- Remark
If the mode uses UDP mode, the internal P2P connection will use UDP mode; if TCP mode is used, the P2P connection will use TCP connection. If AUTO mode is used, the SDK will automatically switch internally, once to UDP mode and once to TCP mode.
If you do not manually stop the device search, the SDK will first search the LAN for the device you are connected to when connecting (matching by UID or IP, UID first, then IP), if found, it will go directly to the LAN, so, If your UID is correct, you can connect if the IP address and port are wrong.
When the device is not in the LAN, the SDK connection will behave differently depending on the parameters:
- URL and UID exist at the same time. The SDK first uses UID to connect. If the connection fails, it uses IP to connect.
- Only UID, the SDK will only use UID to connect.
- Only URL, SDK will only use URL to connect.
- Quote
typedef struct _IVYIO_URL_
{
char szUrl[256]; // IP or DDNS
unsigned short usPort; // IP or IP corresponding to DDNS
}ATTRIBUTE_PACKED IVYIO_URL, *PIVYIO_URL;
- Call example
IVYIO_URL url;
memset(&url, 0, sizeof(url));
strcpy(url.szUrl, "192.168.1.1");
url.usPort = 88;
IVYIO_HANDLE handle = IVYIO_Create_1(&url, "ABCDABCDABCDABCDABCD2222", "username", "password", IVYIO_P2P_MODE_UDP, 1);
4.2 Create SDK handle (2) (Foscam devices recommend using this interface)
IVYIO_HANDLE IVYIO_API IVYIO_CreateEx_1(IVYIO_URL *url, char *szUid, char *szMac, char *szUser, char *szPassword, IVYIO_P2P_MODE mode, int devType, int streamType)
- describe
The function of this interface is consistent with IVYIO_Create. The same parameters have the same meaning and function (refer to IVYIO_Create). All descriptions are applicable to this interface. The following mainly describes the meaning of different parameters.
- Parameters
url | Same as IVYIO_Create |
---|---|
szUid | Same as IVYIO_Create |
szMac | MAC of the target device, can be empty |
szUser | Same as IVYIO_Create |
szPassword | Same as IVYIO_Create |
mode | Same as IVYIO_Create |
devType | Device type, see IVYIO_DEV_TYPE definition, the device type can also be obtained from IVYIO_Discovery |
streamType | Open the stream type of the device, main stream or sub-stream, see IVYIO_VIDEO_STREAM_TYPE definition |
- Call example
// Create SDK handle for Foscam IPC with main stream video
IVYIO_URL url;
memset(&url, 0, sizeof(url));
strcpy(url.szUrl, "192.168.1.1");
url.usPort = 88;
IVYIO_HANDLE handle = IVYIO_CreateEx_1(&url, "ABCDABCDABCDABCDABCD2222", "", "admin", "", IVYIO_P2P_MODE_UDP, IVYIO_DEV_FOS_IPC, IVYIO_MAIN_VIDEO_STREAM);
- Remark
How to use UID to distinguish a Foscam device or an IVY device. If the 21 bits of the UID (starting from 0) are ‘2’ or ‘4’, it means that the device is an IVY device. In other cases, it means that the device is a Foscam device.
4.3 Destroy SDK handle
- describe
Destroy the SDK handle and release resources
void IVYIO_API IVYIO_Destroy(IVYIO_HANDLE handle)
- Parameters
handle | SDK handle |
---|
- return value
none
- Remark
After calling this interface, all the memory occupied by the SDK instance corresponding to the handle is released.
Please do not destroy the same handle in different threads. The SDK cannot handle this operation and will cause a crash.
In order to allow multiple destruction operations to be carried out at the same time, the SDK cannot guarantee the destruction of the same handle. If the SDK guarantees that the same handle is destroyed in different threads, then when multiple handles are destroyed at the same time, the running speed will become very slow. Slow because the SDK must use synchronization to ensure that handles are destroyed one by one.
4.4 Detect the status of the device corresponding to the current handle
- describe
Detect current device status, whether online or offline
IVYIO_HANDLE_STATE IVYIO_API IVYIO_CheckHandle(IVYIO_HANDLE handle)
- Parameters
handle | SDK handle |
---|
- return value
Device status, see definition IVYIO_HANDLE_STATE
0 | Initialization state |
---|---|
1 | Connecting |
2 | Equipment online |
3 | Device offline |
4 | Maximum number of users reached |
5 | Device is locked |
6 | Incorrect username or password |
7 | Access Denied |
8 | Unknown |
9 | Illegal handle |
10 | User cancels operation |
- Quote
typedef enum
{
IVYIO_HANDLE_STATE_INIT = 0,
IVYIO_HANDLE_STATE_CONNECTTING = 1,
IVYIO_HANDLE_STATE_ONLINE = 2,
IVYIO_HANDLE_STATE_OFFLINE = 3,
IVYIO_HANDLE_STATE_MAX_USERS = 4,
IVYIO_HANDLE_STATE_LOCKED = 5,
IVYIO_HANDLE_STATE_USR_OR_PWD_ERR = 6,
IVYIO_HANDLE_STATE_DENY = 7,
IVYIO_HANDLE_STATE_UNKNOWN,
IVYIO_HANDLE_STATE_INVALID_HANDLE
}IVYIO_HANDLE_STATE;
- Remark
Some states only exist for a moment and may not be obtained, such as IVYIO_HANDLE_STATE_USR_OR_PWD_ERR. If the password is incorrect, the device may disconnect from the SDK, so the state may become IVYIO_HANDLE_STATE_OFFLINE.
For IVYIO_HANDLE_STATE_MAX_USERS/IVYIO_HANDLE_STATE_LOCKED/IVYIO_HANDLE_STATE_USR_OR_PWD_ERR/
IVYIO_HANDLE_STATE_DENY Several states can be judged using the return result of IVYIO_Login, because this result is the most accurate and easy to process.
If the current device is an IVY device or FoscamIPC, it is recommended not to use this interface. It is recommended to use IVYIO_GetEvent to determine whether the device is disconnected. Other statuses can be obtained from the login interface.
- Call example
while (bRunning)
{
IVYIO_HANDLE_STATE state = IVYIO_CheckHandle(handle);
switch (state)
{
case IVYIO_HANDLE_STATE_INIT:
case IVYIO_HANDLE_STATE_CONNECTTING:
// SDK is connecting device
break;
case IVYIO_HANDLE_STATE_ONLINE:
// SDK connected already.
break;
case IVYIO_HANDLE_STATE_INVALID_HANDLE:
// Handle error
break;
case IVYIO_HANDLE_STATE_OFFLINE:
// SDK disconnected
break;
default:
// Other state can ignore
break;
}
}
4.5 Log in to the device
- describe
Login device
IVYIO_RESULT IVYIO_API IVYIO_Login(IVYIO_HANDLE handle, int iTimeout)
- Parameters
handle | SDK handle |
---|---|
iTimeout | Timeout time, unit ms |
- return value
Operation result
0 | Success |
---|---|
1 | Failed |
2 | Handle error |
3 | Wrong username and password |
4 | Parameter error |
5 | API runtime error |
6 | Access Denied |
7 | The device is locked |
8 | Maximum number of users reached |
9 | Intercom occupied |
10 | The user has canceled the operation |
11 | timeout |
12 | Unsupported operation |
13 | Unknown |
14 | Not online |
- Quote
typedef enum
{
IVYIO_RESULT_OK = 0,
IVYIO_RESULT_FAIL,
IVYIO_RESULT_HANDLE_ERR,
IVYIO_RESULT_USR_OR_PWD_ERR,
IVYIO_RESULT_ARGS_ERR,
IVYIO_RESULT_APITIME_ERR,
IVYIO_RESULT_DENY,
IVYIO_RESULT_LOCKED,
IVYIO_RESULT_MAX_USER,
IVYIO_RESULT_TALK_OPENED_BY_OTHERS,
IVYIO_RESULT_CANCEL_BY_USER,
IVYIO_RESULT_TIMEOUT,
IVYIO_RESULT_UNSUPPORT,
IVYIO_RESULT_UNKNOWN,
IVYIO_RESULT_OFFLINE
}IVYIO_RESULT;
- Call example
//Login in 5s
IVYIO_RESULT rst = IVYIO_Login(handle, 1000 * 5);
4.6 Log out of the device
- describe
Log out of device
void IVYIO_API IVYIO_Logout(IVYIO_HANDLE handle)
- Parameters
handle | SDK handle |
---|
- Remark
The logout operation only disconnects all connections from the device and does not release resources.
For IVY devices, after the connection is disconnected, the SDK will not reconnect, and IVYIO_Login needs to be called again to connect again.
For Foscam devices, after the connection is disconnected, the SDK will automatically reconnect. Therefore, if you do not want the Foscam device to automatically reconnect, you can call IVYIO_Destroy to destroy the handle.
If you find that you cannot connect to the device, it may be more effective to create a handle again after IVYIO_Destroy to log in.
- Call example
IVYIO_Destory(handle);
4.7 Obtain the TURN server information of the P2P connection after successful login
- describe
Obtain TURN server information for P2P connection after successful login
void IVYIO_API IVYIO_GetCurTurnServer(IVYIO_HANDLE handle, IVYIO_TURN_INFO *turn)
- Parameters
handle | SDK handle |
---|---|
IVYIO_TURN_INFO | turn server information |
- Remark
Please ensure that this interface is called after successful login (login api). If it is a LAN, the turn information will not be filled.
Please note that IVYIO_TURN_INFO->ip may contain the ‘\n’ character, and there will be characters after it (2 lines may appear when printing this string). This is the information returned by p2p, do not miss it, so please ensure that this IVYIO_TURN_INFO ->The ip string is processed as if it ends with ‘\0’.
The characters after ‘\n’ are signs for the p2p library to handle ipv4/ipv6.
If IVYIO_TURN_INFO->ip is saved in a file, the ip may occupy two lines.
For example: the obtained IP is 28.32.3.42, and the actual value in the memory is “28.32.3.42\n2”. Please pay attention to “\n”
- Quote
typedef struct _IVYIO_TURN_INFO_
{
unsigned short port;
char ip[64];
} IVYIO_TURN_INFO, *PIVYIO_TURN_INFO;
- Call example
IVYIO_TURN_INFO turn;
memset(&turn, 0, sizeof(turn));
IVYIO_GetCurTurnServer(handle, &turn);
4.8 Specify P2P turn server
- describe
Use the designated P2P Turn server. After using it, the SDK directly transfers the request dispatch server and directly connects to Turn to start drilling holes.
IVYIO_RESULT IVYIO_API IVYIO_UseTurnServer(IVYIO_HANDLE handle, IVYIO_TURN_INFO *turn)
- Parameters
handle | SDK handle |
---|---|
IVYIO_TURN_INFO | turn server information |
- Remark
After setting turn, the SDK will no longer request the dispatch server. Instead, it will directly use the set turn server to make a P2P connection, which can save the time of requesting the dispatch server.
If the turn is empty, or the turn is illegal, for example, the IP length is 0 and the port is 0, the SDK will automatically request the dispatch server to ensure that p2p can run normally.
- Please use this interface after creating but before logging in.
- If you want to change the turn server, please destroy and then create and then call this interface.
- Quote
typedef struct _IVYIO_TURN_INFO_
{
unsigned short port;
char ip[64];
} IVYIO_TURN_INFO, *PIVYIO_TURN_INFO;
- Call example
IVYIO_TURN_INFO turn;
memset(&turn, 0, sizeof(turn));
// read turn info from file
XXXX_Read(&turn);
IVYIO_UseTurnServer(handle, &turn);
4.9 Specify FoscamP2P connection dispatch server area
- describe
When the device is an IVY device and the character corresponding to UID[22] is one of “GHIJ”, the client needs to specify the dispatch server area to which the SDK is connected; if not specified, the SDK will connect to all dispatch servers.
IVYIO_RESULT IVYIO_API IVYIO_SetDispatchLocationType(IVYIO_HANDLE handle, int location)
- Parameters
handle | SDK handle |
---|---|
location | Region 0: Domestic 1: Foreign |
- Remark
This interface supports IVY devices. You must call this interface before logging in, otherwise all dispatch servers will be connected by default within the SDK;
If the location value is illegal, the SDK will also connect to all dispatch servers.
- Call example
IVYIO_HANDLE handle = IVYIO_CreateXXX(......);
// indicate china
IVYIO_SetDispatchLocationType(handle, 0);
IVYIO_login(handle);
...
5. Device live streaming
5.1 Open live video
- describe
Open video
IVYIO_RESULT IVYIO_API IVYIO_OpenVideo(IVYIO_HANDLE handle, void *args, int iTimeout, int iChannel)
- Parameters
handle | SDK handle |
---|---|
args | Open video parameters, different devices have different parameters |
iTimeout | Timeout, unit ms |
iChannel | Channel number, multiple devices can be opened at one time, expressed in bits (bit0-bit31 represents channels 0-31), such as 0x06, indicating opening channel 1 and channel 2 |
- return value
Operation result
- Remark
Since this interface supports multiple devices to open videos, different devices will have different inputs for the args parameters. When you call this interface to open a video, the SDK will apply for the memory (video buffer, audio buffer) and decoder required for live broadcast. When you call to close the video, the SDK will release the applied memory for the decoder. . At the same time, the media channel is also connected at this time, but the connection will not be disconnected when it is closed.
Foscam IPC / IVY IPC | The args parameter is a pointer to the IVYIO_OPEN_VIDEO_ARGS_TYPE0 structure. The value of the structure member openVideoArgsType must be specified as 0; iChannel is 0) |
---|---|
IVY NVR | The args parameter is a pointer to the IVYIO_OPEN_VIDEO_ARGS_TYPE0 structure. The value of the structure member openVideoArgsType must be specified as 0; iChannel is expressed in bits, bit0 - bit31 represents channel 1-channel 32, multiple channels can be specified at the same time) |
Foscam NVR | The args parameter bit points to a pointer to the IVYIO_OPEN_VIDEO_ARGS_TYPE1 structure. The value of the structure member openVideoArgsType must be specified as 1; iChannel is expressed in bits, bit0 - bit31 represents channel 1-channel 32, and multiple channels can be specified at the same time |
- Notice
Please ensure that IVYIO_OpenVideo / IVYIO_CloseVideo / IVYIO_OpenPlaybackEx / IVYIO_OpenPlayback / IVYIO_ClosePlayback are called serially and not in parallel. Otherwise, the live broadcast or playback video stream may not be obtained, mainly because of these few Stateful maintenance of interfaces.
- Quote
typedef struct _IVYIO_OPEN_VIDEO_ARGS_TYPE0_
{
int openVideoArgsType; // always 0
int streamType; // 0: main stream 1: sub stream
}ATTRIBUTE_PACKED IVYIO_OPEN_VIDEO_ARGS_TYPE0, *PIVYIO_OPEN_VIDEO_ARGS_TYPE0;
typedef struct _IVYIO_OPEN_VIDEO_ARGS_TYPE1_
{
int openVideoArgsType; // always 1
int streamType; // 0: main stream 1: sub stream
int videoMode; // please set 0
int qcMode; // please set 0
int chMode; // please set 0
int reDecChs; // please set 0
}ATTRIBUTE_PACKED IVYIO_OPEN_VIDEO_ARGS_TYPE1, *PIVYIO_OPEN_VIDEO_ARGS_TYPE1;
- Call example
if (IVYIO_DEV_IPC == devType || IVYIO_DEV_FOS_IPC == devType || IVYIO_DEV_FOS_DOORBELL == devType)
{
// Foscam IPC / IVY IPC open video with main stream
IVYIO_OPEN_VIDEO_ARGS_TYPE0 open;
open.openVideoArgsType = 0;
open.streamType = 0;
IVYIO_RESULT rst = IVYIO_OpenVideo(handle, &open, 1000 * 5, 0);
}
else if (IVYIO_DEV_NVR == devType)
{
// IVY NVR open video with main stream in channel 1 and channel 3
IVYIO_OPEN_VIDEO_ARGS_TYPE0 open;
open.openVideoArgsType = 0;
open.streamType = 0;
IVYIO_RESULT rst = IVYIO_OpenVideo(handle, &open, 1000 * 5, 0x05);
}
else if (IVYIO_DEV_FOS_NVR == devType)
{
// Foscam NVR open video with main stream in channel 1 and channel 2
IVYIO_OPEN_VIDEO_ARGS_TYPE1 open;
open.openVideoArgsType = 1;
open.streamType = 0;
open.videoMode = 0;
open.qcMode = 0;
open.chMode = 0;
open.reDecChs = 0;
IVYIO_RESULT rst = IVYIO_OpenVideo(handle, &open, 1000 * 5, 0x03);
}
5.2 Close live video
- describe
Close video
IVYIO_RESULT IVYIO_API IVYIO_CloseVideo(IVYIO_HANDLE handle, int iTimeout, int iChannel)
- Parameters
handle | SDK handle |
---|---|
iTimeout | Timeout, unit ms |
iChannel | Channel number, Foscam IPC / IVY IPC channel value is 0, Foscam NVR / IVY NVR specifies bitwise to close the channel |
- return value
Operation result
- Remark
The closing operation will release the corresponding video memory. Therefore, do not obtain video data before closing the video or do not use the data that has been obtained (unless the data has been copied to your own memory), otherwise it will cause a crash.
- Call example
if (IVYIO_DEV_IPC == devType || IVYIO_DEV_FOS_IPC == devType || IVYIO_DEV_FOS_DOORBELL == devType)
{
// Foscam IPC / IVY IPC close video
IVYIO_RESULT rst = IVYIO_CloseVideo(handle, 1000 * 5, 0);
}
else if (IVYIO_DEV_NVR == devType || IVYIO_DEV_FOS_NVR == devType)
{
// IVY NVR / Foscam NVR close video channel 4 and channel 5
IVYIO_RESULT rst = IVYIO_CloseVideo(handle, 1000 * 5, 0x18);
}
- Notice
Please ensure that IVYIO_OpenVideo / IVYIO_CloseVideo / IVYIO_OpenPlaybackEx / IVYIO_OpenPlayback / IVYIO_ClosePlayback are called serially and not in parallel. Otherwise, the live broadcast or playback video stream may not be obtained, mainly because of these few Stateful maintenance of interfaces.
5.3 Turn on live audio
- describe
Turn on audio
IVYIO_RESULT IVYIO_API IVYIO_OpenAudio(IVYIO_HANDLE handle, IVYIO_AUDIO_STREAM_TYPE stream, int iTimeout, int iChannel)
- Parameters
handle | SDK handle |
---|---|
stream | Audio stream type, 0: main stream 1: sub-stream |
iTimeout | Timeout, unit ms |
iChannel | Channel number, same as opening video |
- return value
Operation result
- Remark
Before opening the audio, you must open the video, because only when the video is opened, the media channel will establish a connection with the device. Similarly, if the video is closed, the audio cannot be opened, because although the media channel is not closed when the video is closed, But the audio buffer has been released.
- Call example
if (IVYIO_DEV_IPC == devType || IVYIO_DEV_FOS_IPC == devType || IVYIO_DEV_FOS_DOORBELL == devType)
{
// Foscam IPC / IVY IPC open audio with main stream
IVYIO_RESULT rst = IVYIO_OpenAudio(handle, IVYIO_MAIN_AUDIO_STREAM, 1000 * 5, 0);
}
else if (IVYIO_DEV_NVR == devType)
{
// IVY NVR open audio with main stream in channel 1 and channel 3
IVYIO_RESULT rst = IVYIO_OpenAudio(handle, IVYIO_MAIN_AUDIO_STREAM, 1000 * 5, 0x05);
}
else if (IVYIO_DEV_FOS_NVR == devType)
{
// We don't need to call this api, because Foscam NVR opened audio already when call open video api.
}
5.4 Turn off live audio
- describe
Turn off audio
IVYIO_RESULT IVYIO_API IVYIO_CloseAudio(IVYIO_HANDLE handle, int iTimeout, int iChannel)
- Parameters
handle | SDK handle |
---|---|
iTimeout | Timeout, unit ms |
iChannel | Channel number, same as opening video |
- return value
Operation result
- Remark
none
- Call example
if (IVYIO_DEV_IPC == devType || IVYIO_DEV_FOS_IPC == devType || IVYIO_DEV_FOS_DOORBELL == devType)
{
// Foscam IPC / IVY IPC close video
IVYIO_RESULT rst = IVYIO_CloseAudio(handle, 1000 * 5, 0);
}
else if (IVYIO_DEV_NVR == devType)
{
// IVY NVR / Foscam NVR close video channel 4 and channel 5
IVYIO_RESULT rst = IVYIO_CloseAudio(handle, 1000 * 5, 0x18);
}
else if (IVYIO_DEV_FOS_NVR == devType)
{
// We don't need to call this api, because Foscam NVR closed audio already when call close video api.
}
5.5 Start live recording
- describe
Start recording
IVYIO_RESULT IVYIO_API IVYIO_StartRecord(IVYIO_HANDLE handle, IVYIO_RECORD_TYPE type, const char *szFileName, int iMaxSize, int iChannel)
- Parameters
handle | SDK handle |
---|---|
type | Video type 0: AVI 1: MP4 |
szFileName | Full path name of video |
iMaxSize | Maximum size of video file, 0 means using the default value of 256M, unit is M |
iChannel | Channels 0-31, only one channel can be used at a time |
- return value
Operation result
- Remark
If the recording reaches the maximum value, a recording reaches the maximum value event will be generated. If the resolution is changed, a resolution change event will also be generated.
- Events that may occur during recording
Event ID | Meaning | Processing method |
---|---|---|
2052 | Not enough space | Stop recording |
2053 | File reaches maximum size | Stop recording and re-record |
2054 | Resolution changed | Stop recording and re-record |
2055 | Path does not exist | Stop recording |
2056 | Unknown recording error | Stop recording |
typedef enum
{
IVYIO_RECORD_ERROR_NO_ENOUGE_SPACE = 2052,
IVYIO_RECORD_ERROR_MAX_FILE,
IVYIO_RECORD_ERROR_SOLUTION_CHG,
IVYIO_RECORD_ERROR_FILE_PATH_NOEXIST,
IVYIO_RECORD_ERROR_UNKNOW
}IVYIO_RECORD_EVENT;
- Call example
if (IVYIO_DEV_FOS_IPC == devType || IVYIO_DEV_IPC == devType || IVYIO_DEV_FOS_DOORBELL == devType)
{
#ifdef _WIN32
IVYIO_RESULT rst = IVYIO_StartRecord(handle, IVYIO_RECORD_MP4, "c:\\record.mp4", 0, 0);
#else
IVYIO_RESULT rst = IVYIO_StartRecord(handle, IVYIO_RECORD_MP4, "/record/record.mp4", 0, 0);
#endif
}
else if (IVYIO_DEV_FOS_NVR == devType || IVYIO_DEV_NVR == devType)
{
// Start record on channel 5
#ifdef _WIN32
IVYIO_RESULT rst = IVYIO_StartRecord(handle, IVYIO_RECORD_MP4, "c:\\record.mp4", 0, 5);
#else
IVYIO_RESULT rst = IVYIO_StartRecord(handle, IVYIO_RECORD_MP4, "/record/record.mp4", 0, 5);
#endif
}
5.6 Stop live recording
- describe
Stop recording
IVYIO_RESULT IVYIO_API IVYIO_StopRecord(IVYIO_HANDLE handle, int iChannel)
- Parameters
handle | SDK handle |
---|---|
iChannel | Channels 0-31, only one channel can be used at a time |
- return value
Operation result
- Call example
if (IVYIO_DEV_FOS_IPC == devType || IVYIO_DEV_IPC == devType || IVYIO_DEV_FOS_DOORBELL == devType)
{
#ifdef _WIN32
IVYIO_RESULT rst = IVYIO_StopRecord(handle, 0);
#else
IVYIO_RESULT rst = IVYIO_StopRecord(handle, 0);
#endif
}
else if (IVYIO_DEV_FOS_NVR == devType || IVYIO_DEV_NVR == devType)
{
// Start record on channel 5
IVYIO_RESULT rst = IVYIO_StopRecord(handle, 5);
}
6. Talkback
6.1 Open intercom
- describe
Turn on intercom
IVYIO_RESULT IVYIO_API IVYIO_OpenTalk(IVYIO_HANDLE handle, int iTimeout, int iChannel)
- Parameters
handle | SDK handle |
---|---|
iTimeout | Timeout, unit ms |
iChannel | Channel number 0-31, only one channel can be opened at a time. If you want to open channel 0, iChannel is 0. If you want to open channel 1, iChannel is 1 |
- return value
Operation result
- Call example
if (IVYIO_DEV_IPC == devType || IVYIO_DEV_FOS_IPC == devType || IVYIO_DEV_FOS_DOORBELL == devType)
{
IVYIO_RESULT rst = IVYIO_OpenTalk(handle, 1000 * 5, 0);
}
else if (IVYIO_DEV_NVR == devType || IVYIO_DEV_FOS_NVR == devType)
{
// Open talk channel 2
IVYIO_RESULT rst = IVYIO_OpenTalk(handle, 1000 * 5, 2);
}
6.2 Turn off intercom
- describe
Turn off intercom
IVYIO_RESULT IVYIO_API IVYIO_CloseTalk(IVYIO_HANDLE handle, int iTimeout, int iChannel)
- Parameters
handle | SDK handle |
---|---|
iTimeout | Timeout, unit ms |
iChannel | Open intercom |
- return value
Operation result
- Call example
if (IVYIO_DEV_IPC == devType || IVYIO_DEV_FOS_IPC == devType || IVYIO_DEV_FOS_DOORBELL == devType)
{
IVYIO_RESULT rst = IVYIO_CloseTalk(handle, 1000 * 5, 0);
}
else if (IVYIO_DEV_NVR == devType || IVYIO_DEV_FOS_NVR == devType)
{
// Close talk channel 2
IVYIO_RESULT rst = IVYIO_CloseTalk(handle, 1000 * 5, 2);
}
6.3 Send intercom data
- describe
Send intercom data
IVYIO_RESULT IVYIO_API IVYIO_SendTalkData(IVYIO_HANDLE handle, unsigned char *data, int iSizeOfData, int iChannel)
- Parameters
handle | SDK handle |
---|---|
data | intercom data buffer |
iSizeOfData | Intercom data size |
iChannel | Open intercom |
- return value
Operation result
- Call example
unsigned char talkData[960] = {0};
// Get talk data to talkData
// Talk data sample is 8000, data size is 960 bytes
...
if (IVYIO_DEV_IPC == devType || IVYIO_DEV_FOS_IPC == devType || IVYIO_DEV_FOS_DOORBELL == devType)
{
IVYIO_RESULT rst = IVYIO_SendTalkData(handle, talkData, sizeof(talkData), 0);
}
else if (IVYIO_DEV_NVR == devType || IVYIO_DEV_FOS_NVR == devType)
{
// Send talk to channel 2
IVYIO_RESULT rst = IVYIO_SendTalkData(handle, talkData, sizeof(talkData), 2);
}
7. Device playback
7.1 Get the recording list of the device
- describe
Get playback list
IVYIO_RESULT IVYIO_API IVYIO_GetPlaybackRecordList(IVYIO_HANDLE handle, void *args, void *list, int iTimeout, int iChannel)
- Parameters
handle | SDK handle |
---|---|
args | Pointer to the request recording list structure |
list | Pointer to playback list structure |
iTimeout | Timeout, unit ms |
iChannel | Channel number, same as opening video |
- return value
Operation result
- Remark
**The video search time cannot span days. It can be from the beginning to the end of the day at most, 0:00 - 23:59:59; usually applications search for videos on a certain day **
- Args and lists corresponding to different device types
device type | args | list |
---|---|---|
IVY IPC | IVYIO_GET_RECORD_LIST_ARGS_TYPE0 | IVY_RECORD_LIST_ARGS_TYPE0 |
IVY NVR | IVYIO_GET_RECORD_LIST_ARGS_TYPE0 | IVY_RECORD_LIST_ARGS_TYPE0 |
Foscam IPC | IVYIO_GET_RECORD_LIST_ARGS_TYPE2 | IVYIO_RECORD_LIST_ARGS_TYPE2 |
Foscam IPC (if supported by bit5 in capability set val12) | IVYIO_GET_RECORD_LIST_ARGS_TYPE4 | IVYIO_RECORD_LIST_ARGS_TYPE4 |
Foscam NVR | IVYIO_GET_RECORD_LIST_ARGS_TYPE3 | IVYIO_RECORD_LIST_ARGS_TYPE3 |
- type definition in IVYIO_GET_RECORD_LIST_ARGS_TYPE0
Recording Type | Value |
---|---|
Manual recording | 1 |
Schedule recording | 2 |
Mobile alarm video | 4 |
Sound alarm video | 8 |
IO alarm video | 16 |
Temperature alarm video | 32 |
Humidity alarm video | 64 |
Humanoid detection alarm video | 128 |
One-click alarm recording | 256 |
The recording type is expressed in bits. If you want to search for multiple types of recordings, please set the type of the IVYIO_GET_RECORD_LIST_ARGS_TYPE0 structure in bits.
//Get play back records list
typedef struct _IVYIO_GET_RECORD_LIST_ARGS_TYPE0_
{
int getRecordListArgsType; // always set 0
unsigned long long sTime; // start time, timestamp, unit second
unsigned long long eTime; // end time, timestamp, unit second
int type; // record type
int startNo; // Start index for search recording
int cnt; // Search count, max 40;
} ATTRIBUTE_PACKED IVYIO_GET_RECORD_LIST_ARGS_TYPE0, *PIVYIO_GET_RECORD_LIST_ARGS_TYPE0;
// Play back records list
typedef struct _IVYIO_RECORD_INFO_TYPE0_ {
char channel;
unsigned long long sTime; // start time, timestamp, unit second
unsigned long long eTime; // end time, timestamp, unit second
unsigned int recordType; // record type, same as type in IVYIO_GET_RECORD_LIST_ARGS_TYPE0
} ATTRIBUTE_PACKED IVYIO_RECORD_INFO_TYPE0, *PIVYIO_RECORD_INFO_TYPE0;
typedef struct _IVYIO_RECORD_LIST_ARGS_TYPE0_
{
unsigned int totalCnt;
unsigned int curCnt;
IVYIO_RECORD_INFO_TYPE0 list[40];
} ATTRIBUTE_PACKED IVYIO_RECORD_LIST_ARGS_TYPE0, *PIVYIO_RECORD_LIST_ARGS_TYPE0;
- recordType definition in IVYIO_GET_RECORD_LIST_ARGS_TYPE2
Recording Type | Value |
---|---|
Schedule recording | 0 |
Alarm video | 1 |
All videos | 2 |
#define MAX_COUNT_OF_RECORD_FOS 10
#define MAX_LENGTH_OF_RECORD_FOS 256
typedef struct _IVYIO_GET_RECORD_LIST_ARGS_TYPE2_
{
int getRecordListArgsType; // always set 2
char recordPath[256]; // fill zero for each byte
unsigned int startTime; // Start time, UTC time, unit second
unsigned int endTime; // End time, UTC Time, unit second
int recordType; // 0:schedule 1:alarm 2:all
int startNo;
}ATTRIBUTE_PACKED IVYIO_GET_RECORD_LIST_ARGS_TYPE2, *PIVYIO_GET_RECORD_LIST_ARGS_TYPE2;
typedef struct _IVYIO_RECORD_LIST_ARGS_TYPE2_
{
int totalCnt; //total count.
int curCnt; //current count.
char recordInfo[MAX_COUNT_OF_RECORD_FOS][MAX_LENGTH_OF_RECORD_FOS];
}ATTRIBUTE_PACKED IVYIO_RECORD_LIST_ARGS_TYPE2, *PIVYIO_RECORD_LIST_ARGS_TYPE2;
- recordType definition in IVYIO_GET_RECORD_LIST_ARGS_TYPE4
Recording Type | Value |
---|---|
Schedule recording | 0x00000001 << 0 |
Manual recording | 0x00000001 << 1 |
Mobile alarm recording | 0x00000001 << 2 |
Sound alarm video | 0x00000001 << 3 |
IO alarm recording | 0x00000001 << 4 |
Temperature alarm video | 0x00000001 << 5 |
Humidity alarm video | 0x00000001 << 6 |
Humanoid alarm video | 0x00000001 << 7 |
LIVECD recording | 0x00000001 << 8 |
TM alarm video | 0x00000001 << 9 |
Button alarm recording | 0x00000001 << 10 |
Cross-line alarm video | 0x00000001 << 11 |
Message alarm video | 0x00000001 << 12 |
Face alarm video | 0x00000001 << 13 |
#define MAX_COUNT_OF_RECORD_FOS 10
#define MAX_LENGTH_OF_RECORD_FOS 256
typedef enum
{
IVYIO_FOS_RECORD_TYPE_V3_SCHEDULE = 0x00000001 << 0, // schedule
IVYIO_FOS_RECORD_TYPE_V3_MANUAL = 0x00000001 << 1, // Manual
IVYIO_FOS_RECORD_TYPE_V3_MDALARM = 0x00000001 << 2, //Motion alarm
IVYIO_FOS_RECORD_TYPE_V3_SDALARM = 0x00000001 << 3, // Sound alarm
IVYIO_FOS_RECORD_TYPE_V3_IOALARM = 0x00000001 << 4, // IO alarm
IVYIO_FOS_RECORD_TYPE_V3_TDALARM = 0x00000001 << 5, // temperature
IVYIO_FOS_RECORD_TYPE_V3_HDALARM = 0x00000001 << 6, // Humidity
IVYIO_FOS_RECORD_TYPE_V3_HMALARM = 0x00000001 << 7, // Humanoid alarm
IVYIO_FOS_RECORD_TYPE_V3_LIVERCD = 0x00000001 << 8,
IVYIO_FOS_RECORD_TYPE_V3_TMALARM = 0x00000001 << 9,
IVYIO_FOS_RECORD_TYPE_V3_BKALARM = 0x00000001 << 10, // Key
IVYIO_FOS_RECORD_TYPE_V3_CLALARM = 0x00000001 << 11, // Crossing the line
IVYIO_FOS_RECORD_TYPE_V3_LMALARM = 0x00000001 << 12, // Leave a message
IVYIO_FOS_RECORD_TYPE_V3_FDALAR = 0x00000001 << 13, // Face
IVYIO_FOS_RECORD_TYPE_V3_CRALARM = 0x00000001 << 15 // Vehicle
} IVYIO_FOS_RECORD_TYPE_V3;
typedef struct _IVYIO_GET_RECORD_LIST_ARGS_TYPE4_
{
int getRecordListArgsType; // always 4
int recordPath; // Must be 0, SD card
unsigned int startTime; // timestamp, unit second
unsigned int endTime; // timestamp, unit second
int recordType; // See IVYIO_FOS_RECORD_TYPE_V3, each bit represents a record type
int startNo;
int cnt; // max 50
}ATTRIBUTE_PACKED IVYIO_GET_RECORD_LIST_ARGS_TYPE4, *PIVYIO_GET_RECORD_LIST_ARGS_TYPE4;
typedef struct _IVYIO_RECORD_INFO_TYPE4_
{
unsigned int startTime; // timestamp, unit second
unsigned int endTime; // timestamp, unit second
unsigned int recordType; // See IVYIO_FOS_RECORD_TYPE_V3
char fileName[256];
}ATTRIBUTE_PACKED IVYIO_RECORD_INFO_TYPE4, *PIVYIO_RECORD_INFO_TYPE4;
typedef struct _IVYIO_RECORD_LIST_ARGS_TYPE4_
{
int totalCnt;
int curCnt;
IVYIO_RECORD_INFO_TYPE4 list[50];
}ATTRIBUTE_PACKED IVYIO_RECORD_LIST_ARGS_TYPE4, *PIVYIO_RECORD_LIST_ARGS_TYPE4;
- recordType definition in IVYIO_GET_RECORD_LIST_ARGS_TYPE3
Note: 1. The channel number searched by Foscam NVR is expressed in bits. Do not search multiple channels separately, otherwise the data obtained will only be the content of the last searched channel; 2. In order to optimize the search video Speed, only when startNO is 0, the SDK will search for videos (FoscamNVR search video interface will search for all videos at once), if it is not 0, it will simply go to the memory to get the data
Recording Type | Value |
---|---|
Schedule recording | 1 |
Manual recording | 2 |
Mobile alarm video | 4 |
io alarm video | 8 |
Each video is represented by bits, and multiple videos can be searched at the same time.
typedef struct _IVYIO_GET_RECORD_LIST_ARGS_TYPE3_
{
int getRecordListArgsType;
unsigned long long startTime; // unit is second, timestamp
unsigned long long endTime; // unit is second, timestamp
int recordType; // 1:schedule 2:manual 4:motion 8:ioalarm 1|2|4|8:all
int startNo;
}ATTRIBUTE_PACKED IVYIO_GET_RECORD_LIST_ARGS_TYPE3, *PIVYIO_GET_RECORD_LIST_ARGS_TYPE3;
typedef struct _IVYIO_RECORD_INFO_
{
unsigned int indexNO;
char channel;
unsigned int fileSize;
unsigned int tmStart;
unsigned int tmEnd;
char recordType;
}ATTRIBUTE_PACKED IVYIO_RECORD_INFO, *PIVYIO_RECORD_INFO;
typedef struct _IVYIO_RECORD_LIST_ARGS_TYPE3_
{
int total;
int curCnt;
IVYIO_RECORD_INFO recordInfo[MAX_COUNT_OF_RECORD_FOS];
}ATTRIBUTE_PACKED IVYIO_RECORD_LIST_ARGS_TYPE3, *PIVYIO_RECORD_LIST_ARGS_TYPE3;
- Call example
if (IVYIO_DEV_IPC == devType)
{
// IVY IPC
// Get all type of recording list from index 0
// Search recordings between 2021-04-28 00:00:00 - 2021-04-28 23:59:59
unsigned long long startUTCTime = 1619539200; // A day start
unsigned long long endUTCTime = 1619539200 + 24 * 60 * 60 - 1; // A day end
IVYIO_GET_RECORD_LIST_ARGS_TYPE0 get;
memset(&get, 0, sizeof(get));
get.getRecordListArgsType = 0;
get.sTime = startUTCTime;
get.eTime = endUTCTime;
get.startNo = 0;
get.cnt = 40;
get.type = 1 | 2 | 4 | 8;
IVYIO_RECORD_LIST_ARGS_TYPE0 list;
memset(&list, 0, sizeof(list));
IVYIO_RESULT rst = IVYIO_GetPlaybackRecordList(handle, &get, list, 1000 * 10, 0);
}
else if (IVYIO_DEV_NVR == devType)
{
// IVY NVR
// Get type '1/2/4/8' recording list from index 0
// Search recordings between 2021-04-28 00:00:00 - 2021-04-28 23:59:59 at channel0/1/2
unsigned long long startUTCTime = 1619539200; // A day start
unsigned long long endUTCTime = 1619539200 + 24 * 60 * 60; // A day end
IVYIO_GET_RECORD_LIST_ARGS_TYPE0 get;
memset(&get, 0, sizeof(get));
get.getRecordListArgsType = 0;
get.sTime = startUTCTime;
get.eTime = endUTCTime;
get.startNo = 0;
get.cnt = 40;
get.type = 1 | 2 | 4 | 8;
IVYIO_RECORD_LIST_ARGS_TYPE0 list;
memset(&list, 0, sizeof(list));
IVYIO_RESULT rst = IVYIO_GetPlaybackRecordList(handle, &get, list, 1000 * 10, 0x07);
}
else if (IVYIO_DEV_FOS_IPC == devType)
{
// Foscam IPC
if (Ability_val12_bit5_support())
{
IVYIO_GET_RECORD_LIST_ARGS_TYPE4 get;
memset(&get, 0, sizeof(get));
get.getRecordListArgsType = 4;
get.recordPath = 0;
get.startTime = 1619539200; // 2021-04-28 00:00:00
get.endTime = 1619539200 + 24 * 60 * 60 - 1; // 2021-04-28 23:59:59
get.recordType = IVYIO_FOS_RECORD_TYPE_V3_SCHEDULE | IVYIO_FOS_RECORD_TYPE_V3_MANUAL | IVYIO_FOS_RECORD_TYPE_V3_MDALARM | IVYIO_FOS_RECORD_TYPE_V3_SDALARM;
get.startNo = 10; // From index 10
get.cnt = 50;
IVYIO_RECORD_LIST_ARGS_TYPE4 list;
memset(&list, 0, sizeof(list));
IVYIO_RESULT rst = IVYIO_GetPlaybackRecordList(handle, &get, list, 1000 * 10, 0);
}
else
{
// All Foscam IPC support
IVYIO_GET_RECORD_LIST_ARGS_TYPE2 get;
memset(&get, 0, sizeof(get));
get.getRecordListArgsType = 2;
get.startTime = 1619539200; // 2021-04-28 00:00:00
get.endTime = 1619539200 + 24 * 60 * 60 - 1; // 2021-04-28 23:59:59
get.recordType = 2; // all type
get.startNo = 10; // From index 10
IVYIO_RECORD_LIST_ARGS_TYPE2 list;
memset(&list, 0, sizeof(list));
IVYIO_RESULT rst = IVYIO_GetPlaybackRecordList(handle, &get, list, 1000 * 10, 0);
}
}
else if (IVYIO_DEV_FOS_NVR == devType)
{
// Foscam NVR
// Get all type of recordings on channel0/1/2
IVYIO_GET_RECORD_LIST_ARGS_TYPE3 get;
get.getRecordListArgsType = 3;
get.startTime = 1619539200; // 2021-04-28 00:00:00
get.endTime = 1619539200 + 24 * 60 * 60 - 1; // 2021-04-28 23:59:59
get.recordType = 1 | 2 | 4 | 8; // All type recordings
get.startNo = 0;
IVYIO_RECORD_LIST_ARGS_TYPE3 list;
memset(&list, 0, sizeof(list));
IVYIO_RESULT rst = IVYIO_GetPlaybackRecordList(handle, &get, list, 1000 * 10, 0x07);
}
7.2 Open playback
- describe
Open recording. Different device types have different parameters.
IVYIO_RESULT IVYIO_API IVYIO_OpenPlayback(IVYIO_HANDLE handle, void *args, int iTimeout, int iChannel)
- Parameters
handle | SDK handle |
---|---|
args | Pointer to the open playback structure |
iTimeout | Timeout, unit ms |
iChannel | Channel number, same as opening video |
- return value
Operation result
- Remark
- The same method is used to open playback and live broadcast. The audio and video buffers and decoders for playback are applied when opening and released when closing.
- Foscam NVR uses sTime and eTime of IVYIO_OPEN_PLAY_BACK_ARGS_TYPE2 to indicate that the recording time range is to be opened, and offsetTime is a time in the range, indicating that playback starts from this time. Generally, the time is actually the start and end time of a certain day.
- If it is FoscamNVR, we recommend turning on a whole day’s recording, so that the data stream will transfer the whole day’s data, which is very convenient.
- Notice
Please ensure that IVYIO_OpenVideo / IVYIO_CloseVideo / IVYIO_OpenPlaybackEx / IVYIO_OpenPlayback / IVYIO_ClosePlayback are called serially and not in parallel. Otherwise, the live broadcast or playback video stream may not be obtained, mainly because of these few Stateful maintenance of interfaces.
- Structure type corresponding to args
device type | args |
---|---|
Foscam IPC | String, an SD card recording address |
Foscam Doorbell | String, an SD card recording address |
Foscam NVR | IVYIO_OPEN_PLAY_BACK_ARGS_TYPE2 |
IVY IPC | IVYIO_OPEN_PLAY_BACK_ARGS_TYPE0 |
IVY NVR | IVYIO_OPEN_PLAY_BACK_ARGS_TYPE0 |
If the current device is IPC, please refer to OpenVideo for setting the iChannel value.
- Structure definition
typedef struct _IVYIO_OPEN_PLAY_BACK_ARGS_TYPE2_
{
int openPlaybackArgsType; // always 2
unsigned int sTime; // Search recording start time
unsigned int eTime; // Search recording end time
unsigned int offsetTime; // Time between in start time and end time
int videoMode; // always set 0
}ATTRIBUTE_PACKED IVYIO_OPEN_PLAY_BACK_ARGS_TYPE2, *PIVYIO_OPEN_PLAY_BACK_ARGS_TYPE2;
typedef struct _IVYIO_OPEN_PLAY_BACK_ARGS_TYPE0_
{
int openPlaybackArgsType; // always 0
unsigned long long sTime; // Search recording start time
unsigned long long eTime; // Search recording end time
int streamType; // 0: main 1: sub
}ATTRIBUTE_PACKED IVYIO_OPEN_PLAY_BACK_ARGS_TYPE0, *PIVYIO_OPEN_PLAY_BACK_ARGS_TYPE0;
- Call example
if (IVYIO_DEV_FOS_IPC == devType || IVYIO_DEV_FOS_DOORBELL == devType)
{
// Foscam IPC
if (Ability_val12_bit5_support())
{
IVYIO_GET_RECORD_LIST_ARGS_TYPE4 get;
memset(&get, 0, sizeof(get));
get.getRecordListArgsType = 4;
get.recordPath = 0;
get.startTime = 1619539200;
get.endTime = 1619539200 + 24 * 60 * 60 - 1;
get.recordType = IVYIO_FOS_RECORD_TYPE_V3_SCHEDULE | IVYIO_FOS_RECORD_TYPE_V3_MANUAL | IVYIO_FOS_RECORD_TYPE_V3_MDALARM | IVYIO_FOS_RECORD_TYPE_V3_SDALARM;
get.startNo = 10; // From index 10
get.cnt = 50;
IVYIO_RECORD_LIST_ARGS_TYPE4 list;
memset(&list, 0, sizeof(list));
if (IVYIO_RESULT_OK == IVYIO_GetPlaybackRecordList(handle, &get, list, 1000 * 10, 0))
{
rst = IVYIO_OpenPlayback(handle, list.list[0], 1000 * 5, 0);
}
}
else
{
// All Foscam IPC support
IVYIO_GET_RECORD_LIST_ARGS_TYPE2 get;
memset(&get, 0, sizeof(get));
get.getRecordListArgsType = 2;
get.startTime = 1619539200; // 2021-04-28 00:00:00
get.endTime = 1619539200 + 24 * 60 * 60 - 1; // 2021-04-28 23:59:59
get.recordType = 2; // all type
get.startNo = 10; // From index 10
IVYIO_RECORD_LIST_ARGS_TYPE2 list;
memset(&list, 0, sizeof(list));
if (IVYIO_RESULT_OK == IVYIO_GetPlaybackRecordList(handle, &get, list, 1000 * 10, 0))
{
rst = IVYIO_OpenPlayback(handle, list.recordInfo[0], 1000 * 5, 0);
}
}
}
else if (IVYIO_DEV_FOS_NVR == devType)
{
IVYIO_GET_RECORD_LIST_ARGS_TYPE3 get;
get.getRecordListArgsType = 3;
get.startTime = 1619539200; // 2021-04-28 00:00:00
get.endTime = 1619539200 + 24 * 60 * 60 - 1; // 2021-04-28 23:59:59
get.recordType = 1 | 2 | 4 | 8; // All type recordings
get.startNo = 0;
#ifdef _WE_SUGGEST
// Open all day of recordings
IVYIO_RECORD_LIST_ARGS_TYPE3 list;
memset(&list, 0, sizeof(list));
if (IVYIO_RSULT_OK == IVYIO_GetPlaybackRecordList(handle, &get, list, 1000 * 10, 0x07))
{
// Open channel 0 and channel 1
IVYIO_OPEN_PLAY_BACK_ARGS_TYPE2 open;
open.openPlaybackArgsType = 2;
open.sTime = 1619539200; // 2021-04-28 00:00:00
open.eTime = 1619539200 + 24 * 60 * 60 - 1; // 2021-04-28 23:59:59
open.offsetTime = 0;
open.videoMode = 0;
rst = IVYIO_OpenPlayback(handle, &open, 1000 * 5, 0x07);
}
#else
//Open one recording
IVYIO_RECORD_LIST_ARGS_TYPE3 list;
memset(&list, 0, sizeof(list));
if (IVYIO_RSULT_OK == IVYIO_GetPlaybackRecordList(handle, &get, list, 1000 * 10, 0x07))
{
// Open channel 0 and channel 1
IVYIO_OPEN_PLAY_BACK_ARGS_TYPE2 open;
open.openPlaybackArgsType = 2;
open.sTime = list.recordInfo[0].tmStart;
open.eTime = list.recordInfo[0].tmEnd;
open.offsetTime = 0;
open.videoMode = 0;
rst = IVYIO_OpenPlayback(handle, &open, 1000 * 5, 0x07);
}
#endif
}
else if (IVY_DEV_IPC == devType)
{
IVYIO_GET_RECORD_LIST_ARGS_TYPE0 get;
memset(&get, 0, sizeof(get));
get.getRecordListArgsType = 0;
get.sTime = 1619539200;
get.eTime = 1619539200 + 24 * 60 * 60 - 1;
get.startNo = 0;
get.cnt = 40;
get.type = 1 | 2 | 4 | 8;
IVYIO_RECORD_LIST_ARGS_TYPE0 list;
memset(&list, 0, sizeof(list));
if (IVYIO_RESULT_OK == IVYIO_GetPlaybackRecordList(handle, &get, list, 1000 * 10, 0))
{
IVYIO_OPEN_PLAY_BACK_ARGS_TYPE0 open;
open.openPlaybackArgsType = 0;
open.sTime = list.list[0].sTime;
open.eTime = list.list[0].eTime;
open.streamType = 0; // main stream
rst = IVYIO_OpenPlayback(handle, &open, 1000 * 5, 0);
}
}
else if (IVY_DEV_NVR == devType)
{
IVYIO_GET_RECORD_LIST_ARGS_TYPE0 get;
memset(&get, 0, sizeof(get));
get.getRecordListArgsType = 0;
get.sTime = 1619539200;
get.eTime = 1619539200 + 24 * 60 * 60 - 1;
get.startNo = 0;
get.cnt = 40;
get.type = 1 | 2 | 4 | 8;
IVYIO_RECORD_LIST_ARGS_TYPE0 list;
memset(&list, 0, sizeof(list));
if (IVYIO_RESULT_OK == IVYIO_GetPlaybackRecordList(handle, &get, list, 1000 * 10, 0x07))
{
IVYIO_OPEN_PLAY_BACK_ARGS_TYPE0 open;
open.openPlaybackArgsType = 0;
open.sTime = list.list[0].sTime;
open.eTime = list.list[0].eTime;
open.streamType = 0; // main stream
rst = IVYIO_OpenPlayback(handle, &open, 1000 * 5, 0x07);
}
}
7.3 Close playback
- Turn off playback
IVYIO_RESULT IVYIO_API IVYIO_ClosePlayback(IVYIO_HANDLE handle, void *args, int iTimeout, int iChannel)
- Parameters
handle | SDK handle |
---|---|
args | Pointer to the close playback structure |
iTimeout | Timeout, unit ms |
iChannel | channel number |
- return value
Operation result
- The args parameter structure is as follows
device type | args |
---|---|
Foscam IPC | none |
Foscam NVR | none |
Foscam DoorBell | none |
IVY IPC | IVYIO_CLOSE_PLAY_BACK_ARGS_TYPE0 |
IVY NVR | IVYIO_CLOSE_PLAY_BACK_ARGS_TYPE0 |
If it is an IPC device, whether it is Foscam or IVY, the value of iChannel must be consistent with OpenPlayback
- Notice
Please ensure that IVYIO_OpenVideo / IVYIO_CloseVideo / IVYIO_OpenPlaybackEx / IVYIO_OpenPlayback / IVYIO_ClosePlayback are called serially and not in parallel. Otherwise, the live broadcast or playback video stream may not be obtained, mainly because of these few Stateful maintenance of interfaces.
- Call example
if (IVYIO_DEV_FOS_IPC == devType || IVYIO_DEV_FOS_DOORBELL == devType || IVYIO_DEV_FOS_NVR == devType)
{
IVYIO_RESULT rst = IVYIO_ClosePlayback(handle, NULL, 1000 * 5, 0);
}
else if (IVYIO_DEV_NVR == devType || IVYIO_DEV_IPC == devType)
{
IVYIO_CLOSE_PLAY_BACK_ARGS_TYPE0 close;
close.openPlaybackArgsType = 0;
IVYIO_RESULT rst = IVYIO_ClosePlayback(handle, &close, 1000 * 5, 0);
}
7.4 Playback Control
- describe
Playback control
IVYIO_RESULT IVYIO_API IVYIO_PlaybackCmdEx(IVYIO_HANDLE handle, IVYIO_PLAYBACK_CMD cmd, unsigned char *cmdData, unsigned char *outData, int *sizeOfOutData, int iTimeout, int iChannel)
- Parameters
handle | SDK handle |
---|---|
cmd | 0: Playback pause 1: Playback resume 2: SEEK playback 3: Fast playback 4: Slow playback 5: Reverse playback (3-5 is currently only supported by Foscam NVR) |
cmdData | Data structure corresponding to the command |
outData | Return data memory |
sizeOfOutData | Return the length of data |
iTimeout | Timeout, unit ms |
iChannel | Channel number 0-31, only one channel can be operated at a time. If you want to open channel 0, iChannel is 0. If you want to open channel 1, iChannel is 1 |
- return value
Operation result
1. If it is IPC, no channel is required. If it is NVR, all commands on the current interface are for all channels.
- Precautions
1. For SEEK operation, Foscam IPC will return the real SEEK time; other devices will not return it.
2. Only Foscam NVR supports fast play/slow play/reverse play operations, other devices do not support it.
3. It is best to open the Foscam NVR recording from the beginning to the end of the day, so that we only need to SEEK to watch the recording at any time without reopening the playback.
Other devices must be opened according to the searched recording time or path, so SEEK can only be opened within the opened recording period. If it is another recording, it must be opened again.
typedef enum
{
IVYIO_PLAYBACK_CMD_PAUSE = 0,
IVYIO_PLAYBACK_CMD_RESUME = 1,
IVYIO_PLAYBACK_CMD_SEEK = 2,
IVYIO_PLAYBACK_CMD_FAST_FORWARD = 3,
IVYIO_PLAYBACK_CMD_SLOW_FORWARD = 4,
IVYIO_PLAYBACK_CMD_FAST_REVERSE = 5
}IVYIO_PLAYBACK_CMD;
Playback commands supported by different devices
Foscam IPC
Command | Whether this command is supported | cmdData structure | outData structure |
---|---|---|---|
0 | YES | ignore | ignore |
1 | YES | ignore | ignore |
2 | YES | Unsigned integer data pointer, indicating the time to SEEK | Unsigned integer data pointer; indicating the real seek time returned by the device. The SEEK time passed in by the application is only an approximate time for the device, and the device will Returns a real time, the application should be based on the returned SEEK |
3 | NO | ||
4 | NO | ||
5 | NO |
- Foscam NVR
Command | Whether this command is supported | cmdData structure | outData structure |
---|---|---|---|
0 | YES | IVYIO_PLAY_BACK_PAUSE_TYPE0 | ignore |
1 | YES | IVYIO_PLAY_BACK_RESUME_TYPE0 | ignore |
2 | YES | Unsigned integer data pointer, SEEK time, the time unit is seconds, for example, currently 00:00:00 - 23:59:59, the SEEK value is the timestamp of a certain time point in the middle | ignore |
3 | YES | IVYIO_FOS_NVR_PLAY_BACK_CMD_VALUE | ignore |
4 | YES | IVYIO_FOS_NVR_PLAY_BACK_CMD_VALUE | ignore |
5 | YES | IVYIO_FOS_NVR_PLAY_BACK_CMD_VALUE | ignore |
// Foscam NVR fast/slow-forward/fast-reverse
// fast forward: 4x, 8x, 16x, 32 -> value: 4, 8, 16, 32
// slow forward: 1/2x, 1/4x, 1/8x, 1/16x, 1/32x -> value: 2, 4, 8, 16, 32
// fast reverse: 4x, 8x, 16x, 32 -> value: 4, 8, 16, 32
typedef struct _IVYIO_FOS_NVR_PLAY_BACK_CMD_VALUE_
{
unsigned int time; // start time, unit second
int value; // cmd value
}ATTRIBUTE_PACKED IVYIO_FOS_NVR_PLAY_BACK_CMD_VALUE, *PIVYIO_FOS_NVR_PLAY_BACK_CMD_VALUE;
- *IVYIO_FOS_NVR_PLAY_BACK_CMD_VALUE.value data description: *
PLAYBACK_CMD_FAST_FORWARD | Support (4/8/16/32 times), corresponding value bit 4/8/16/32 |
---|---|
PLAYBACK_CMD_SLOW_FORWARD | Support (2/4/8/16/32 times), corresponding value bit 2/4/8/16/32 |
PLAYBACK_CMD_FAST_REVERSE | Support (4/8/16/32 times), corresponding value 4/8/16/32 |
For Foscam NVR, if you have played fast/slow/reverse and want to return to normal, call PLAYBACK_CMD_FAST_FORWARD, specify the time, and set value to 1
- IVY IPC / IVY NVR
Command | Whether this command is supported | cmdData structure | outData structure |
---|---|---|---|
0 | YES | IVYIO_PLAY_BACK_PAUSE_TYPE0 | ignore |
1 | YES | IVYIO_PLAY_BACK_RESUME_TYPE0 | ignore |
2 | YES | IVYIO_PLAY_BACK_SEEK_ARGS_TYPE0(IPC: milliseconds NVR: seconds) | ignore |
3 | YES | IVYIO_PLAY_BACK_FAST_FORWARD_ARGS_TYPE0 | ignore |
4 | NO | ||
5 | NO |
- IVYIO_PLAY_BACK_FAST_FORWARD_ARGS_TYPE0.value data description:
IVYIO_PLAYBACK_CMD_FAST_FORWARD | Support (2/4/8/16/32 times), corresponding value 2/4/8/16/32 |
---|
typedef struct _IVYIO_PLAY_BACK_SEEK_ARGS_TYPE0_
{
int openPlaybackArgsType; // always 0
unsigned long long time; // Jet height unit s, Thor ms
}ATTRIBUTE_PACKED IVYIO_PLAY_BACK_SEEK_ARGS_TYPE0, *PIVYIO_PLAY_BACK_SEEK_ARGS_TYPE0;
typedef struct _IVYIO_PLAY_BACK_PAUSE_TYPE0_
{
int openPlaybackArgsType; // always 0
}ATTRIBUTE_PACKED IVYIO_PLAY_BACK_PAUSE_TYPE0, *PIVYIO_PLAY_BACK_PAUSE_TYPE0;
typedef struct _IVYIO_PLAY_BACK_RESUME_TYPE0_
{
int openPlaybackArgsType; // always 0
}ATTRIBUTE_PACKED IVYIO_PLAY_BACK_RESUME_TYPE0, *PIVYIO_PLAY_BACK_RESUME_TYPE0;
typedef struct _IVYIO_PLAY_BACK_FAST_FORWARD_ARGS_TYPE0_
{
int openPlaybackArgsType;
int value;
}ATTRIBUTE_PACKED IVYIO_PLAY_BACK_FAST_FORWARD_ARGS_TYPE0, *PIVYIO_PLAY_BACK_FAST_FORWARD_ARGS_TYPE0;
- Call example
if (IVYIO_DEV_FOS_IPC == devType || IVYIO_DEV_FOS_DOORBELL == devType)
{
// Pause
// Device will stop sending playback data
IVYIO_RESULT rst = IVYIO_PlaybackCmdEx(handle, IVYIO_PLAYBACK_CMD_PAUSE, NULL, NULL, NULL, 1000 * 5, 0);
...
// Resume
// Device will send playback data again
rst = IVYIO_PlaybackCmdEx(handle, IVYIO_PLAYBACK_CMD_RESUME, NULL, NULL, NULL, 1000 * 5, 0);
...
// Seek
// 2021/4/29 1:00:00 timestamp is 1619629200
// 2021/4/29 2:00:00 timestamp is 1619632800
// 2021/4/29 1:30:00 timestamp is 1619631000
// if one recording start time is 1:00:00 and end time is 2:00:00, want to seek to 1:30:00
unsigned int seekTime = 1619631000;
unsigned int actualSeekTime = 0;
rst = IVYIO_PlaybackCmdEx(handle, IVYIO_PLAYBACK_CMD_SEEK, &seekTime, &actualSeekTime, sizeof(unsigned int), 1000 * 5, 0);
}
if (IVYIO_DEV_FOS_NVR == devType)
{
// Pause
// Device will stop send playback data on all channels, we can ignore channel
IVYIO_RESULT rst = IVYIO_PlaybackCmdEx(handle, IVYIO_PLAYBACK_CMD_PAUSE, NULL, NULL, NULL, 1000 * 5, 0);
...
// Resume
// Device will send playback data again on all channels, we can ignore channel
rst = IVYIO_PlaybackCmdEx(handle, IVYIO_PLAYBACK_CMD_RESUME, NULL, NULL, NULL, 1000 * 5, 0);
...
// Seek
// 2021-04-28 00:00:00 start timestamp 1619539200
// 2021-04-28 23:59:59 end timestamp 1619539200 + 24 * 60 * 60 - 1
// For Foscam NVR we open playback all day (00:00:00-23:59:59)usually, then we can seek any time instead of opening playback other time.
// This will seek to the time on all channels, we can ignore channel
unsigned int seekTime = 1619631000;
rst = IVYIO_PlaybackCmdEx(handle, IVYIO_PLAYBACK_CMD_SEEK, &seekTime, NULL, 0, 1000 * 5, 0);
...
// Fast forward on all channels, we can ignore channels
// 32x for timestamp 1619539200 (2021-04-28 00:00:00)
IVYIO_FOS_NVR_PLAY_BACK_CMD_VALUE fastForward;
fastForward.time = 1619539200;
fastForward.value = 32;
rst = IVYIO_PlaybackCmdEx(handle, IVYIO_PLAYBACK_CMD_FAST_FORWARD, &fastForward, NULL, sizeof(unsigned int), 1000 * 5, 0);
...
// Slow forward on all channels, we can ignore channels
// 16x for timestamp 1619539200 (2021-04-28 00:00:00)
IVYIO_FOS_NVR_PLAY_BACK_CMD_VALUE slowForward;
slowForward.time = 1619539200;
slowForward.value = 16;
rst = IVYIO_PlaybackCmdEx(handle, IVYIO_PLAYBACK_CMD_SLOW_FORWARD, &slowForward, NULL, sizeof(unsigned int), 1000 * 5, 0);
...
// Fast reverse on all channels, we can ignore channels
// 8x for timestamp 1619539200 (2021-04-28 00:00:00)
IVYIO_FOS_NVR_PLAY_BACK_CMD_VALUE fastReverse;
fastReverse.time = 1619539200;
fastReverse.value = 8;
rst = IVYIO_PlaybackCmdEx(handle, IVYIO_PLAYBACK_CMD_FAST_REVERSE, &fastReverse, NULL, sizeof(unsigned int), 1000 * 5, 0);
}
else if (IVYIO_DEV_IPC == devType)
{
// Pause
// Device will stop sending playback data
IVYIO_PLAY_BACK_PAUSE_TYPE0 pause;
pause.openPlaybackArgsType = 0;
IVYIO_RESULT rst = IVYIO_PlaybackCmdEx(handle, IVYIO_PLAYBACK_CMD_PAUSE, &pause, NULL, NULL, 1000 * 5, 0);
...
// Resume
// Device will send playback data again
IVYIO_PLAY_BACK_RESUME_TYPE0 resume;
resume.openPlaybackArgsType = 0;
rst = IVYIO_PlaybackCmdEx(handle, IVYIO_PLAYBACK_CMD_RESUME, &resume, NULL, NULL, 1000 * 5, 0);
...
// Seek
// 2021/4/29 1:00:00 timestamp is 1619629200
// 2021/4/29 2:00:00 timestamp is 1619632800
// 2021/4/29 1:30:00 timestamp is 1619631000
// if one recording start time is 1:00:00 and end time is 2:00:00, want to seek to 1:30:00
IVYIO_PLAY_BACK_SEEK_ARGS_TYPE0 seek;
seek.openPlaybackArgsType = 0;
seek.time = 1619631000;
rst = IVYIO_PlaybackCmdEx(handle, IVYIO_PLAYBACK_CMD_RESUME, &seek, NULL, NULL, 1000 * 5, 0);
}
else if (IVYIO_DEV_NVR == devType)
{
// If devcies are online on channel 0 / 1 / 2
// Pause
// Device will stop sending playback data on channel 0 / 1 / 2
IVYIO_PLAY_BACK_PAUSE_TYPE0 pause;
pause.openPlaybackArgsType = 0;
IVYIO_RESULT rst = IVYIO_PlaybackCmdEx(handle, IVYIO_PLAYBACK_CMD_PAUSE, &pause, NULL, NULL, 1000 * 5, 0x07);
...
// Resume
// Device will send playback data again on channel 0 / 1 / 2
IVYIO_PLAY_BACK_RESUME_TYPE0 resume;
resume.openPlaybackArgsType = 0;
rst = IVYIO_PlaybackCmdEx(handle, IVYIO_PLAYBACK_CMD_RESUME, &resume, NULL, NULL, 1000 * 5, 0x07);
...
// Seek
// 2021/4/29 1:00:00 timestamp is 1619629200
// 2021/4/29 2:00:00 timestamp is 1619632800
// 2021/4/29 1:30:00 timestamp is 1619631000
// if one recording start time is 1:00:00 and end time is 2:00:00, want to seek to 1:30:00
IVYIO_PLAY_BACK_SEEK_ARGS_TYPE0 seek;
seek.openPlaybackArgsType = 0;
seek.time = 1619631000;
rst = IVYIO_PlaybackCmdEx(handle, IVYIO_PLAYBACK_CMD_RESUME, &seek, NULL, NULL, 1000 * 5, 0x07);
}
7.5 Start playback video download (IVY device)
- describe
To download videos, this API can only download IVY IPC and IVY NVR videos.
Note: Playback and video download cannot be opened at the same time
IVYIO_RESULT IVYIO_API IVYIO_DownLoadRecord(IVYIO_HANDLE handle, IVYIO_DOWNLOAD_RECORD *records, const char *dstPath, int timeout)
- Parameters
handle | SDK handle |
---|---|
records | Pointer to IVYIO_DOWNLOAD_RECORD structure. The required parameters can be obtained from the interface for searching video |
dstPath | Destination path, does not need to include the file name, the file name will be automatically generated internally by the SDK |
timeout | timeout |
typedef struct _IVYIO_DOWNLOAD_RECORD_
{
unsigned int channel; // 0-31 means channel 0 - 31
unsigned int startTime; // recording start time, you can get it from getPlaybackRecordlist api
unsigned int endTime; // recording end time, you can get it from getPlaybackRecordlist api
unsigned int recordType; // see IVY device record type define in IVYIO_GetPlaybackRecordList
}ATTRIBUTE_PACKED IVYIO_DOWNLOAD_RECORD, *PIVYIO_DOWNLOAD_RECORD;
- return value
Operation result
- Generate event
2063 | Recording progress event |
---|
- Remark
This interface only supports IVY devices and FoscamNVR devices, other devices are not supported.
For IV devices, only one video can be downloaded at a time and cannot be downloaded in parallel. If the current video has not been downloaded, the interface will return
IVYIO_RESULT_DOWNLOADING (17), download progress event IVY_CTRL_MSG_RECORD_DOWNLOAD_PROGRESS (2063). The device will disconnect the download connection after sending a piece of video data, so each video needs to call the download interface. Because the SDK will connect every time it is called.
If the video download progress reaches 100%, do not call IVYIO_DownLoadCannel. On the contrary, if the video download does not reach 100%, it can be called and part of the downloaded video can be played.
- Call example
IVYIO_DOWNLOAD_RECORD record;
if (IVYIO_DEV_IPC == devType)
{
record.channel = 0;
record.startTime = 1619751051; // 2021-04-30 10:50:51
record.endTime = 1619751171; // 2021-04-30 10:52:51
record.recordType = 4; // motion detected record
}
else if (IVYIO_DEV_NVR == devType)
{
record.channel = 2; // Download channel 2 recording
record.startTime = 1619751051; // 2021-04-30 10:50:51
record.endTime = 1619751171; // 2021-04-30 10:52:51
record.recordType = 4; // motion detected record
}
#ifdef _WIN32
IVYIO_RESULT rst = IVYIO_DownLoadRecord(handle, &record, "C:\\record.mp4", 1000 * 5);
#else
IVYIO_RESULT rst = IVYIO_DownLoadRecord(handle, &record, "/record/record.mp4", 1000 * 5);
#endif
if (IVYIO_RESULT_OK != rst)
IVYIO_DownLoadCannel();
// Another thread get event
IVYIO_EVENT event;
memset(&event, 0, event);
if (IVYIO_RESULT_OK == IVYIO_GetEvent(handle, &event))
{
if (2063 == event.id)
{
// event.data is json data for prgress, you can parse it.
}
}
#endif
7.6 Cancel playback video download (IVY device)
- describe
Cancel the video download. If the video download progress has reached 100%, there is no need to call this interface. If not, after calling this interface, partially downloaded videos can also be played.
IVYIO_RESULT IVYIO_API IVYIO_DownLoadCancel(IVYIO_HANDLE handle)
- Parameters
handle | SDK handle |
---|
- return value
Operation result
- Remark
This interface only supports IVY devices and FoscamNVR devices, other devices are not supported.
For IVY devices, the SDK for canceling recording download does not send any command to the device, but just disconnects the download connection. When the download interface is called again, the SDK will internally connect to the download channel again.
- Call example
// You can see the chapter 7.5
7.7 Start playback video download (FosamIPC)
- describe
Download FoscamIPC SD card recording
Note: Playback and video download cannot be opened at the same time
IVYIO_RESULT IVYIO_API IVYIO_DownLoadFosIPCRecord(IVYIO_HANDLE handle, const char *srcPath, const char *dstPath, int timeout)
- Parameters
handle | SDK handle |
---|---|
srcPath | Recording source path, which can be obtained through GetPlayBackRecordList |
dstPath | The path to save |
timeout | timeout period |
- return value
Operation result
- Generate event
2063 | Recording progress event |
---|
- Remark
This interface only supports FoscamIPC and is not supported by other devices. The saved video format is MP4
The download progress can be obtained through events. The SDK will give a progress every time it receives a video frame, so the progress may be repeated, and the upper layer needs to do some processing for repeated progress. (Each video frame has a progress because if there are many video frames, it will take a long time before there is progress)
If the progress value is 100, there is no need to call the cancellation interface.
- Call example
if (IVYIO_DEV_FOS_IPC == devType || IVYIO_DEV_FOS_DOORBELL == devType)
{
// srcPath recordInfo from IVYIO_RECORD_LIST_ARGS_TYPE2 or
// fileName of list in IVYIO_RECORD_LIST_ARGS_TYPE4
char szPath[512] = {0};
strcpy(szPath, ...);
#ifdef _WIN32
IVYIO_RESULT rst = IVYIO_DownLoadFosIPCRecord(handle, szPath, "C:\\record.mp4", 1000 * 5);
#else
IVYIO_RESULT rst = IVYIO_DownLoadFosIPCRecord(handle, szPath, "/record/record.mp4", 1000 * 5);
#endif
if (IVYIO_RESULT_OK != rst)
IVYIO_DownLoadFosIPCRecordCancel();
}
// Another thread get event
IVYIO_EVENT event;
memset(&event, 0, event);
if (IVYIO_RESULT_OK == IVYIO_GetEvent(handle, &event))
{
if (2063 == event.id)
{
// event.data is json data for prgress, you can parse it.
}
}
#endif
7.8 Cancel playback video download (FosamIPC)
- describe
Cancel FoscamIPC SD card recording
IVYIO_RESULT IVYIO_API IVYIO_DownLoadFosIPCRecordCancel(IVYIO_HANDLE handle, int timeout)
- Parameters
handle | SDK handle |
---|---|
timeout | timeout period |
- return value
Operation result
- Remark
This interface only supports FoscamIPC and is not supported by other devices.
If the video has not been downloaded, the downloaded part contains legal video data, and the file can be played normally after calling this interface.
- Call example
// You can see the chapter 7.7
7.9 Start playback video download (FosamNVR)
- describe
Download FoscamNVR hard disk recording
Note: Playback and video download cannot be opened at the same time
IVYIO_RESULT IVYIO_API IVYIO_DownLoadFosNVRRecord(IVYIO_HANDLE handle, IVYIO_RECORD_INFO *record, const char *dstPath, int count)
- Parameters
handle | SDK handle |
---|---|
record | IVYIO_RECORD_INFO structure pointer, all data in the structure comes from IVYIO_RECORD_LIST_ARGS_TYPE3 in the result of IVYIO_GetPlaybackRecordList |
dstPath | The path to save, just the path, not the file name, the file name will be automatically generated |
count | The number of downloaded files, also indicates the number of record pointer objects |
typedef struct _IVYIO_RECORD_INFO_
{
unsigned int indexNO;
char channel;
unsigned int fileSize;
unsigned int tmStart;
unsigned int tmEnd;
char recordType;
}ATTRIBUTE_PACKED IVYIO_RECORD_INFO, *PIVYIO_RECORD_INFO;
- return value
Operation result
- Generate event
2063 | Recording progress event |
---|
- Remark
Regardless of whether multiple files or one file are downloaded at a time, the progress value indicates the overall progress after calling the download interface this time.
- Call example
if (IVYIO_DEV_FOS_NVR == devType)
{
IVYIO_RECORD_LIST_ARGS_TYPE3 list;
//Get recording list
...
// Download 10 recordings
for (int i = 0; i < 10; i++)
{
record[i].indexNO = list.recordInfo[i].indexNo;
record[i].channel = list.recordInfo[i].channel;
record[i].fileSize = list.recordInfo[i].fileSize;
record[i].tmStart = list.recordInfo[i].tmStart;
record[i].tmEnd = list.recordInfo[i].tmEnd;
record[i].recordType = list.recordInfo[i].recordType;
}
#ifdef _WIN32
IVYIO_RESULT rst = IVYIO_DownLoadFosNVRRecord(handle, record, "C:\\record", 10);
#else
IVYIO_RESULT rst = IVYIO_DownLoadFosNVRRecord(handle, record, "/record/", 10);
#endif
if (IVYIO_RESULT_OK != rst)
IVYIO_DownloadFosNVRCancel(handle);
}
// Another thread get event
IVYIO_EVENT event;
memset(&event, 0, event);
if (IVYIO_RESULT_OK == IVYIO_GetEvent(handle, &event))
{
if (2063 == event.id)
{
// event.data is json data for prgress, you can parse it.
}
}
#endif
7.10 Cancel playback video download (FosamNVR)
- describe
Cancel FoscamIPC SD card recording
IVYIO_RESULT IVYIO_API IVYIO_DownloadFosNVRCancel(IVYIO_HANDLE handle)
- Parameters
handle | SDK handle |
---|
- return value
Operation result
- Remark
This interface only supports FoscamNVR, not other devices.
- Call example
// You can see the chapter 7.9
8. Get live/playback video and audio data
8.1 Obtain the decoded data of the live broadcast
- describe
Get the decoded data of the live broadcast
IVYIO_RESULT IVYIO_API IVYIO_GetStreamData(IVYIO_HANDLE handle, IVYIO_STREAM_TYPE stream, unsigned char **data, int *iOutLen, int *iSpeed, int iDecodeFmt, int iChannel)
- Parameters
handle | SDK handle |
---|---|
stream | Stream type 0: video stream 1: audio stream |
data | Pointer to the IVYIO_FRAME pointer that stores the media data frame structure |
iOutLen | Get the data size, which includes the frame header |
iSpeed | Media Streaming Speed |
iDecodeFmt | Media data decoding type IVYIO_DECODE_FMT, if audio is obtained, ignore this parameter |
iChannel | Channel 0-31, only one channel can be obtained at a time |
- return value
Operation result
- Remark
The memory required for the obtained media data is maintained within the SDK and does not need to be applied by the caller. However, if you call to close the video, the media data memory will be released, so if you call to close the video, you must ensure that the IVYIO_FRAME pointer is no longer used, otherwise it will cause a crash. (For the caller, the most common situation is to ensure that the thread playing media data exits before calling to close the video)
iChannel: Fill in whichever position of OpenVideo’s iChannel is 1. For example: OpenVideo’s iChannel is 2, which means the first Bit is set to 1, then the iChannel of this function should be filled in with 1.
- Quote
typedef struct _IVYIO_MEDIA_DATA_
{
unsigned int channel;
unsigned int index;
unsigned int iKey;
unsigned int iFrameTag;
unsigned long long pts;
IVYIO_STREAM_TYPE type;
IVYIO_STREAM_FMT fmt;
union
{
IVYIO_VIDEO_INFO video;
IVYIO_AUDIO_INFO audio;
} media;
unsigned int len;
unsigned char data[0];
}ATTRIBUTE_PACKED IVYIO_FRAME, *PIVYIO_FRAME;
typedef enum
{
IVYIO_DEC_TYPE_VIDEORAW,
IVYIO_DEC_TYPE_ARGB32, //packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
IVYIO_DEC_TYPE_RGBA32, //packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
IVYIO_DEC_TYPE_ABGR32, //packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
IVYIO_DEC_TYPE_BGRA32, //packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
IVYIO_DEC_TYPE_RGB24, //packed RGB 8:8:8, 24bpp, RGBRGB...
IVYIO_DEC_TYPE_BGR24, //packed RGB 8:8:8, 24bpp, BGRBGR...
IVYIO_DEC_TYPE_RGB565BE, //packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
IVYIO_DEC_TYPE_RGB565LE, //packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
IVYIO_DEC_TYPE_BGR565BE, //packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian
IVYIO_DEC_TYPE_BGR565LE, //packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian
IVYIO_DEC_TYPE_YUV420,
IVYIO_DEC_TYPE_YUYV422,
IVYIO_DEC_TYPE_UYVY422,
IVYIO_DEC_TYPE_H264,
IVYIO_DEC_TYPE_MJPEG,
IVYIO_DEC_TYPE_MJPEG_BASE64,
IVYIO_DEC_TYPE_H264_BASE64,
IVYIO_DEC_TYPE_AUDIORAW,
IVYIO_DEC_TYPE_G726,
IVYIO_DEC_TYPE_G711U,
IVYIO_DEC_TYPE_PCM,
IVYIO_DEC_TYPE_ADPCM,
IVYIO_DEC_TYPE_G711A,
IVYIO_DEC_TYPE_AAC,
IVYIO_DEC_TYPE_HEVC
}IVYIO_DECODE_FMT;
- Call example
if (IVYIO_DEV_FOS_IPC == devType || IVYIO_DEV_IPC == devType || IVYIO_DEV_FOS_DOORBELL == devType)
{
//Get video in a thread
while (bGetVideoRunning)
{
IVYIO_FRAME *frame = NULL;
int outLen = 0;
int speed = 0;
IVYIO_RESULT rst = IVYIO_GetStreamData(handle, IVYIO_STREAM_VIDEO, (unsigned char **)&frame, &outLen, &speed, IVYIO_DEC_TYPE_YUV420, 0);
if (IVYIO_RESULT_OK == rst && frame->len > 0)
{
// Display frame->data
}
else
{
sleep(10); // Sleep 10ms
}
}
...
//Get audio in another thread
while (bGetAudioRunning)
{
IVYIO_FRAME *frame = NULL;
int outLen = 0;
int speed = 0;
IVYIO_RESULT rst = IVYIO_GetStreamData(handle, IVYIO_STREAM_AUDIO, (unsigned char **)&frame, &outLen, &speed, IVYIO_DEC_TYPE_PCM, 0);
if (IVYIO_RESULT_OK == rst && frame->len > 0)
{
// Display frame->data
}
else
{
sleep(10); // Sleep 10ms
}
}
}
else if (IVYIO_DEV_FOS_NVR == devType || IVYIO_DEV_NVR == devType)
{
// Get channel 2 video in a thread
while (bGetVideoRunning)
{
IVYIO_FRAME *frame = NULL;
int outLen = 0;
int speed = 0;
IVYIO_RESULT rst = IVYIO_GetStreamData(handle, IVYIO_STREAM_VIDEO, (unsigned char **)&frame, &outLen, &speed, IVYIO_DEC_TYPE_YUV420, 2);
if (IVYIO_RESULT_OK == rst && frame->len > 0)
{
// Display frame->data
}
else
{
sleep(10); // Sleep 10ms
}
}
...
// Get channel 2 audio in another thread
while (bGetAudioRunning)
{
IVYIO_FRAME *frame = NULL;
int outLen = 0;
int speed = 0;
IVYIO_RESULT rst = IVYIO_GetStreamData(handle, IVYIO_STREAM_AUDIO, (unsigned char **)&frame, &outLen, &speed, IVYIO_DEC_TYPE_PCM, 2);
if (IVYIO_RESULT_OK == rst && frame->len > 0)
{
// Display frame->data
}
else
{
sleep(10); // Sleep 10ms
}
}
}
8.2 Obtain the original audio and video data of the live broadcast
- describe
Obtain the original audio and video data in the live broadcast
IVYIO_RESULT IVYIO_API IVYIO_GetRawStreamData(IVYIO_HANDLE handle,IVYIO_STREAM_TYPE stream,unsigned char **data,int *iOutLen,int *iSpeed,int iChannel)
- Parameters
handle | SDK handle |
---|---|
stream | Stream type 0: video stream 1: audio stream |
data | Pointer to the IVYIO_FRAME pointer that stores the media data frame structure |
iOutLen | Get the data size, which includes the frame header |
iSpeed | Media Streaming Speed |
iChannel | Channel 0-31, only one channel can be obtained at a time |
- return value
Operation result
- Remark
The data obtained by this interface is not decoded and is original H264 data or H265 data; the audio data is all PCM. If you only obtain audio, this interface is the same as IVYIO_GetStreamData. Notes on data usage are the same as IVYIO_GetStreamData
- Call example
if (IVYIO_DEV_FOS_IPC == devType || IVYIO_DEV_IPC == devType || IVYIO_DEV_FOS_DOORBELL == devType)
{
// Get video in a thread
while (bGetVideoRunning)
{
IVYIO_FRAME *frame = NULL;
int outLen = 0;
int speed = 0;
IVYIO_RESULT rst = IVYIO_GetRawStreamData(handle, IVYIO_STREAM_VIDEO, (unsigned char **)&frame, &outLen, &speed, 0);
if (IVYIO_RESULT_OK == rst && frame->len > 0)
{
// Decode and display frame->data
}
else
{
sleep(10); // Sleep 10ms
}
}
...
//Get audio in another thread
while (bGetAudioRunning)
{
IVYIO_FRAME *frame = NULL;
int outLen = 0;
int speed = 0;
IVYIO_RESULT rst = IVYIO_GetRawStreamData(handle, IVYIO_STREAM_AUDIO, (unsigned char **)&frame, &outLen, &speed, 0);
if (IVYIO_RESULT_OK == rst && frame->len > 0)
{
// Decode and display frame->data
}
else
{
sleep(10); // Sleep 10ms
}
}
}
else if (IVYIO_DEV_FOS_NVR == devType || IVYIO_DEV_NVR == devType)
{
// Get channel 2 video in a thread
while (bGetVideoRunning)
{
IVYIO_FRAME *frame = NULL;
int outLen = 0;
int speed = 0;
IVYIO_RESULT rst = IVYIO_GetRawStreamData(handle, IVYIO_STREAM_VIDEO, (unsigned char **)&frame, &outLen, &speed, 2);
if (IVYIO_RESULT_OK == rst && frame->len > 0)
{
// Decode and display frame->data
}
else
{
sleep(10); // Sleep 10ms
}
}
...
// Get channel 2 audio in another thread
while (bGetAudioRunning)
{
IVYIO_FRAME *frame = NULL;
int outLen = 0;
int speed = 0;
IVYIO_RESULT rst = IVYIO_GetRawStreamData(handle, IVYIO_STREAM_AUDIO, (unsigned char **)&frame, &outLen, &speed, 2);
if (IVYIO_RESULT_OK == rst && frame->len > 0)
{
// Decode and display frame->data
}
else
{
sleep(10); // Sleep 10ms
}
}
}
8.3 Obtain playback of decoded audio and video data
- describe
Get playback media data
IVYIO_RESULT IVYIO_API IVYIO_GetPlaybackStreamData(IVYIO_HANDLE handle, IVYIO_STREAM_TYPE stream, unsigned char **data, int *iOutLen, int *iSpeed, int iDecodeFmt, int iChannel)
- Parameters
handle | SDK handle |
---|---|
stream | Stream type 0: video stream 1: audio stream |
data | Pointer to the IVYIO_FRAME pointer that stores the media data frame structure |
iOutLen | Get the data size, which includes the frame header |
iSpeed | Media Streaming Speed |
iDecodeFmt | Media data decoding type IVYIO_DECODE_FMT, if audio is obtained, ignore this parameter |
iChannel | Channel 0-31, only one channel can be obtained at a time |
- return value
Operation result
- Remark
Notes are the same as IVYIO_GetStreamData. If the current device is an NVR, you may need to know more detailed information about the frame during playback. You can obtain it from the iFrameTag in IVYIO_FRAME. FRAME_TAG_PLAYBACK_E_FRAME can help you know whether the current video has finished playing. If a frame’s iFrameTag is found to be of this type, it means the last frame of the current video, and the data can be ignored.
- Quote
// Ordinary live video or audio frame
#define FRAME_TAG_LIVE_FRAME 0x4556494c
// Normal playback of video or audio frames
#define FRAME_TAG_PLAYBACK_FRAME 0x4b424c50
//The last frame of a video
#define FRAME_TAG_PLAYBACK_E_FRAME 0x46454250
- Call example
if (IVYIO_DEV_FOS_IPC == devType || IVYIO_DEV_IPC == devType || IVYIO_DEV_FOS_DOORBELL == devType)
{
//Get video in a thread
while (bGetVideoRunning)
{
IVYIO_FRAME *frame = NULL;
int outLen = 0;
int speed = 0;
IVYIO_RESULT rst = IVYIO_GetPlaybackStreamData(handle, IVYIO_STREAM_VIDEO, (unsigned char **)&frame, &outLen, &speed, IVYIO_DEC_TYPE_YUV420, 0);
if (IVYIO_RESULT_OK == rst && frame->len > 0)
{
// Display frame->data
}
else
{
sleep(10); // Sleep 10ms
}
}
...
//Get audio in another thread
while (bGetAudioRunning)
{
IVYIO_FRAME *frame = NULL;
int outLen = 0;
int speed = 0;
IVYIO_RESULT rst = IVYIO_GetPlaybackStreamData(handle, IVYIO_STREAM_AUDIO, (unsigned char **)&frame, &outLen, &speed, IVYIO_DEC_TYPE_PCM, 0);
if (IVYIO_RESULT_OK == rst && frame->len > 0)
{
// Display frame->data
}
else
{
sleep(10); // Sleep 10ms
}
}
}
else if (IVYIO_DEV_FOS_NVR == devType || IVYIO_DEV_NVR == devType)
{
// Get channel 2 video in a thread
while (bGetVideoRunning)
{
IVYIO_FRAME *frame = NULL;
int outLen = 0;
int speed = 0;
IVYIO_RESULT rst = IVYIO_GetPlaybackStreamData(handle, IVYIO_STREAM_VIDEO, (unsigned char **)&frame, &outLen, &speed, IVYIO_DEC_TYPE_YUV420, 2);
if (IVYIO_RESULT_OK == rst && frame->len > 0)
{
// Display frame->data
}
else
{
sleep(10); // Sleep 10ms
}
}
...
// Get channel 2 audio in another thread
while (bGetAudioRunning)
{
IVYIO_FRAME *frame = NULL;
int outLen = 0;
int speed = 0;
IVYIO_RESULT rst = IVYIO_GetPlaybackStreamData(handle, IVYIO_STREAM_AUDIO, (unsigned char **)&frame, &outLen, &speed, IVYIO_DEC_TYPE_PCM, 2);
if (IVYIO_RESULT_OK == rst && frame->len > 0)
{
// Display frame->data
}
else
{
sleep(10); // Sleep 10ms
}
}
}
8.4 Obtain and playback original audio and video data
- describe
Get playback original media data
IVYIO_RESULT IVYIO_API IVYIO_GetPlaybackRawStreamData(IVYIO_HANDLE handle,IVYIO_STREAM_TYPE stream,unsigned char **data,int *iOutLen,int *iSpeed, int iChannel)
- Parameters
handle | SDK handle |
---|---|
stream | Stream type 0: video stream 1: audio stream |
data | Pointer to the IVYIO_FRAME pointer that stores the media data frame structure |
iOutLen | Get the data size, which includes the frame header |
iSpeed | Media Streaming Speed |
iChannel | Channel 0-31, only one channel can be obtained at a time |
- return value
Operation result
- Remark
Notes are the same as IVYIO_GetRawStreamData. For the function and definition of iFrameTag in IVYIO_FRAME, please refer to IVYIO_GetPlaybackStreamData
- Call example
if (IVYIO_DEV_FOS_IPC == devType || IVYIO_DEV_IPC == devType || IVYIO_DEV_FOS_DOORBELL == devType)
{
//Get video in a thread
while (bGetVideoRunning)
{
IVYIO_FRAME *frame = NULL;
int outLen = 0;
int speed = 0;
IVYIO_RESULT rst = IVYIO_GetPlaybackRawStreamData(handle, IVYIO_STREAM_VIDEO, (unsigned char **)&frame, &outLen, &speed, 0);
if (IVYIO_RESULT_OK == rst && frame->len > 0)
{
// Decode and display frame->data
}
else
{
sleep(10); // Sleep 10ms
}
}
...
//Get audio in another thread
while (bGetAudioRunning)
{
IVYIO_FRAME *frame = NULL;
int outLen = 0;
int speed = 0;
IVYIO_RESULT rst = IVYIO_GetPlaybackRawStreamData(handle, IVYIO_STREAM_AUDIO, (unsigned char **)&frame, &outLen, &speed, 0);
if (IVYIO_RESULT_OK == rst && frame->len > 0)
{
// Decode and display frame->data
}
else
{
sleep(10); // Sleep 10ms
}
}
}
else if (IVYIO_DEV_FOS_NVR == devType || IVYIO_DEV_NVR == devType)
{
// Get channel 2 video in a thread
while (bGetVideoRunning)
{
IVYIO_FRAME *frame = NULL;
int outLen = 0;
int speed = 0;
IVYIO_RESULT rst = IVYIO_GetPlaybackRawStreamData(handle, IVYIO_STREAM_VIDEO, (unsigned char **)&frame, &outLen, &speed, 2);
if (IVYIO_RESULT_OK == rst && frame->len > 0)
{
// Decode and display frame->data
}
else
{
sleep(10); // Sleep 10ms
}
}
...
//Get channel 2 audio in another thread
while (bGetAudioRunning)
{
IVYIO_FRAME *frame = NULL;
int outLen = 0;
int speed = 0;
IVYIO_RESULT rst = IVYIO_GetPlaybackRawStreamData(handle, IVYIO_STREAM_AUDIO, (unsigned char **)&frame, &outLen, &speed, 2);
if (IVYIO_RESULT_OK == rst && frame->len > 0)
{
// Decode and display frame->data
}
else
{
sleep(10); // Sleep 10ms
}
}
}
8.5 Decode and playback video data
- describe
Decode playback video data
IVYIO_RESULT IVYIO_API IVYIO_DecodePlaybackVideo(IVYIO_HANDLE handle, unsigned char *srcFrame, unsigned char **dstFrame, int *dstFrameSize, int dstDecodeFmt, int channel)
- Parameters
handle | SDK handle |
---|---|
srcFrame | Playback data IVYIO_FRAME structure pointer |
dstFrame | Pointer to the IVYIO_FRAME pointer that stores the decoded data frame structure |
dstFrameSize | The size of the decoded data, including the IVYIO_FRAME header size |
dstDecodeFmt | Decoding format |
channel | channel 0-31 |
- return value
Operation result
- Remark
Note: IVYIO_OpenPlayback must be called before use, because this interface is still related to playback internally and is not an independent interface.
Foscam devices are not supported
- Call example
if (IVYIO_DEV_IPC == devType || IVYIO_DEV_NVR == devType)
{
// Get channel 2 video in a thread
while (bGetVideoRunning)
{
IVY_FRAME *srcFrame = NULL;
// from api 'IVYIO_GetPlaybackRawStreamData'
...
IVYIO_FRAME *dstFrame = NULL;
int outLen = 0;
IVYIO_RESULT rst = IVYIO_DecodePlaybackVideo(handle, (unsigned char *)srcFrame, (unsigned char **)&dstFrame, &outLen, IVYIO_DECODE_YUV420, 2);
if (IVYIO_RESULT_OK == rst && dstFrame->len > 0)
{
// Decode and display dstFrame->data
}
else
{
sleep(5); // Sleep 10ms
}
}
...
}
9. Send command
9.1 Send command (recommended)
- describe
Send commands to set the device or obtain various information or status of the device
IVYIO_RESULT IVYIO_API IVYIO_SendCommand(IVYIO_HANDLE handle, unsigned int cmd, unsigned char *cmdData, int iSizeOfCmdData, unsigned char *response, int *iSizeOfResponse, int iTimeout)
- Parameters
handle | SDK handle |
---|---|
cmd | command ID |
cmdData | command data buffer |
iSizeOfCmdData | Command data buffer size |
response | response data buffer |
iSizeOfResponse | The actual size of the response data returned |
iTimeout | Timeout, unit ms |
- return value
Operation result
- Remark
The range of the cmd parameter should be 22019-42018. The purpose of the ID command within this range is determined by the developer. The SDK is only responsible for transmitting data. The parsing of the specific command is determined by the upper-layer application and the lower-layer embedded; therefore, the format of cmdData and response should be determined by Developer definition.
*If the application is not Android, you need to pay attention to the value of iSizeOfResponse, because the data transmission has been encrypted. If the return is a Json string, do not use iSizeOfResponse, but use strlen(response) yourself. This way you can get the real string length, which will be followed by iSizeOfResponse. Contains several ‘\0’, Android applications do not have this problem. If the return is binary data, just use iSizeOfResponse directly. *
- Call example
// Get device information
memset(szResponse, 0, sizeof(szResponse));
lenOfResponse = sizeof(szResponse);
IVYIO_RESULT rst = IVYIO_SendCommand(handle, 22025, "", (unsigned char *)szResponse, &lenOfResponse, 1000 * 5);
if (IVYIO_RESULT_OK == rst)
{
// The 'ret' field in 'szResponse' is 0, mean success
// Your wil get response text like this:
//{
// "devName" : "RG9vckJlbGw=",
// "devType" : 1000,
// "firmwareVersion" : "2.134.2.19",
// "hardwareVersion" : "1.17.2.5",
// "language" : 2,
// "mac" : "A0E9DA067AEA",
// "model" : 10001,
// "oemCode" : 3000,
// "platType" : 4,
// "productName" : "MBS4010",
// "ret" : 0,
// "sensorType" : 28,
// "serialNo" : "0000000000000001",
// "uid" : "GKBGTPY7BX98TH5BZZZZ7Y8M",
// "wifiType" : 9
//}
}
else
{
// failed!
}
9.2 Send CGI
- describe
Send CGI commands to FoscamIPC and get the results. Other devices do not support it.
IVYIO_RESULT IVYIO_API IVYIO_DoCGI(IVYIO_HANDLE handle, const char *szCGI, char *szXmlResp, int *iSizeOfResp, int iTimeout)
- Parameters
handle | SDK handle |
---|---|
szCGI | CGI commands |
szXmlResp | CGI result, XML structure |
iSizeOfResp | As input is the size of szXmlResp, as output is the actual length of the response result returned |
iTimeout | timeout |
- return value
Operation result
- Remark
This interface only supports FoscamIPC and is not supported by other devices.
- Call example
char szCGI[512] = "cmd=getDevInfo";
char szXML[1024] = {0};
int lenOfXML = sizeof(szXML);
IVYIO_RESULT rst = IVYIO_DoCGI(handle, szCGI, szXML, &lenOfXML, 1000 * 5);
// The szXML data like this:
// <CGI_Result>
// <result>0</result>
// <productName>MBS4010</productName>
// <serialNo>0000000000000001</serialNo>
// <devName>DoorBell</devName>
// <mac>A0E9DA067AEA</mac>
// <year>2021</year>
// <mon>4</mon>
// <day>28</day>
// <hour>13</hour>
// <min>13</min>
// <sec>33</sec>
// <timeZone>0</timeZone>
// <firmwareVer>2.134.2.19</firmwareVer>
// <hardwareVer>1.17.2.5</hardwareVer>
// <pkgTime>2021-04-09_16%3A40%3A00</pkgTime>
// </CGI_Result>
10. Auxiliary interface
10.1 Get events
- describe
Get events. When the device status changes, the device or SDK will send an event to notify the application. The application should respond according to the event.
IVYIO_RESULT IVYIO_API IVYIO_GetEvent(IVYIO_HANDLE handle, IVYIO_EVENT *event)
- Parameters
handle | SDK handle |
---|---|
event | Pointer to event structure IVYIO_EVENT |
- return value
Operation result
- Remark
Normally, the range of event ID is 42019-65535. Events in this range are defined by developers. Similar to sending command IVYIO_SendCommand, the event SDK is only responsible for data transmission and does not parse any data. The purpose and structure of command ID are both Upper-layer application and lower-layer embedded decisions. Note that some events are emitted internally by the SDK and do not fall within the range of 42019-65535.
This interface can only handle events with event data size less than 4K.
- Call example
// Get event in a thread
while (bRunning)
{
IVYIO_EVENT event;
memset(&event, 0, sizeof(event));
if (IVYIO_GetEvent(handle, &event) == IVYIO_RESULT_OK)
{
switch(event.id)
{
case IVY_CTRL_MSG_DAY_NIGHT_MODE_CHG:
// Parse event.data
break;
case IVY_CTRL_MSG_PRESET_CHG:
// Parse event.data
break;
...
default:
break;
}
}
}
10.1.1 Get event 2
- describe
Get the event. When the device status changes, the device or SDK will send an event to notify the application, and the application should respond according to the event. This interface can handle events of any size, as long as the caller gives enough space.
IVYIO_RESULT IVYIO_API IVYIO_GetEvent2(IVYIO_HANDLE handle, IVYIO_EVENT2 *event)
- Parameters
handle | SDK handle |
---|---|
event | Pointer to event structure IVYIO_EVENT2 |
- return value
Operation result
- Remark
Normally, the range of event ID is 42019-65535. Events in this range are defined by developers. Similar to sending command IVYIO_SendCommand, the event SDK is only responsible for data transmission and does not parse any data. The purpose and structure of command ID are both Upper-layer application and lower-layer embedded decisions. Note that some events are emitted internally by the SDK and do not fall within the range of 42019-65535.
event->iLenOfData as input represents the event->data size. If the actual event data is larger than the input buffer size, the interface returns an IVYIO_RESULT_ARGS_ERR error, otherwise event->iLenOfData is modified to the actual data size.
- Call example
// Get event in a thread
const int bufSize = 16 * 1024;
char *eventBuff = new char[bufSize];
memset(eventBuff, 0, bufSize);
IVYIO_EVENT2 event;
memset(&event, 0, sizeof(event));
event->data = eventBuff;
while (bRunning)
{
memset(eventBuff, 0, bufSize);
event->iLenOfData = bufSize;
if (IVYIO_GetEvent2(handle, &event) == IVYIO_RESULT_OK)
{
switch(event.id)
{
case IVY_CTRL_MSG_DAY_NIGHT_MODE_CHG:
// Parse event.data
break;
case IVY_CTRL_MSG_PRESET_CHG:
// Parse event.data
break;
...
default:
break;
}
}
}
delete[] eventBuff;
eventBuff = NULL;
10.2 Convert keyframes into a picture
- describe
Convert a keyframe to an image
IVYIO_RESULT IVYIO_API IVYIO_KeyFrame2Picture(IVYIO_HANDLE handle, char *inData, int iLenOfInData, char *outData, int *iLenOfOutData, int channel);
- Parameters
handle | SDK handle |
---|---|
inData | Pointer to input data buffer |
iLenOfInData | Input data buffer size |
outData | Points to the size of the output data buffer |
iLenOfOutData | Pointer to output buffer size |
channel | channel number |
- return value
Operation result
- Remark
iLenOfOutData is both an input parameter and an output parameter. As an input parameter, it indicates the size of the outData buffer. As an output, it indicates the size of the actual output buffer. If the size as an input parameter is smaller than the actual required buffer size, the function will return an error, but as an output, iLenOfOutData will inform the actual need. The buffer size.
- Call example
IVYIO_FRAME *frame = NULL;
//Get a video frame,
...
if (frame->iKey)
{
char *picture = new char[1024 * 1024 * 10];
int pictureLen = 1024 * 1024 * 10;
if (IVYIO_DEV_FOS_IPC == devType || IVYIO_DEV_IPC == devType || IVYIO_DEV_FOS_DOORBELL == devType)
{
IVYIO_RESULT rst = IVYIO_KeyFrame2Picture(handle, frame->data, frame->len, picture, &pictureLen, 0);
}
else if (IVYIO_DEV_FOS_NVR == devType || IVYIO_DEV_NVR == devType)
{
// Key frame on channel 5 to picture
IVYIO_RESULT rst = IVYIO_KeyFrame2Picture(handle, frame->data, frame->len, picture, &pictureLen, 5);
}
// You can save it to local as a picture.
...
delete[] picture;
picture = NULL;
}
10.3 Query SDK interface calling status
- describe
Query the interface calling status to see if the interface has not been called for a certain period of time. This interface only takes effect when the last parameter of IVYIO_Create_1 is 1.
IVYIO_RESULT IVYIO_API IVYIO_ApiCallTimeIsUp(IVYIO_HANDLE handle, int *state);
- Parameters
handle | SDK handle |
---|---|
state | State 1: The SDK interface has not been called for more than a certain period of time 0: The interface call is normal |
- return value
Operation result
- Remark
This interface only takes effect when the last parameter of IVYIO_Create_1 is 1
- Call example
while (1)
{
int state = -1;
if (IVYIO_RESULT_OK == IVYIO_ApiCallTimeIsUp(handle, &state))
{
if (1 == state)
{
// do someting
}
}
}
11. Doorbell answering interface
Interface applicable scope
This chapter interface is suitable for doorbell answering scenarios.
Doorbell answering scenario: When the doorbell is pressed, the application receives the message that the doorbell has been pressed, and displays it on the interface so that the user can choose whether to answer. If they choose to answer, the application displays video and audio, and can send intercoms and record videos.
11.1 Create doorbell device handle and log in
- describe
Create an SDK instance handle. Although this interface is suitable for doorbells, it is also applicable to other devices (if it is not a doorbell, we recommend using other interfaces to create handles). If the current device type is a doorbell, this interface will automatically log in to the device, but will not return whether the login is successful.
IVYIO_HANDLE IVYIO_API IVYIO_CreateEx_2(IVYIO_URL *url, char *szUid, char *szMac, char *szUser, char *szPassword, IVYIO_P2P_MODE mode, IVYIO_P2P_MODE doorbellMode, int devType, int streamType)
- Parameters
url | Structure that stores the connection address and port of the target device; the address can be DDNS or IP |
---|---|
szUid | UID of the target device, can be empty |
szUser | The user name of the target device, cannot be empty |
szPassword | The password of the target device, cannot be empty |
mode | P2P connection mode 0: UDP mode 1: TCP mode 2: Automatic |
doorbellMode | Doorbell P2P connection mode 3: audio TCP video UDP 4: audio and video are all TCP |
devType | device type |
streamType | IPC stream type, you can ignore it if it is a doorbell device |
The same parameters can refer to the description of IVYIO_CreateEx_1 / IVYIO_CreateEx.
- return value
SDK handle, which is incremented when returning the handle, and will also be incremented after it is created after it is released.
- Remark
mode can only use the values FOS_P2P_MODE_UDP/FOS_P2P_MODE_TCP/FOS_P2P_MODE_AUTO
doorbell can only use IVYIO_P2P_MODE_A_TCP_V_UDP / IVYIO_P2P_MODE_A_V_TCP
If the devType is a doorbell device, the device will be connected when the doorbell part is created, and the usage of the IPC part is still the same as before.
- Quote
typedef struct _IVYIO_URL_
{
char szUrl[256]; // ip or ddns
unsigned short usPort; // port
}ATTRIBUTE_PACKED IVYIO_URL, *PIVYIO_URL;
typedef enum
{
IVYIO_P2P_MODE_UDP = 0,
IVYIO_P2P_MODE_TCP = 1,
IVYIO_P2P_MODE_AUTO = 2,
IVYIO_P2P_MODE_A_TCP_V_UDP = 3,
IVYIO_P2P_MODE_A_V_TCP = 4
}IVYIO_P2P_MODE;
- Call example
//Create doorbell
IVYIO_URL url;
memset(&url, 0, sizeof(url));
strcpy(url.szUrl, "192.168.1.1");
url.usPort = 88;
IVYIO_HANDLE doorBellHandle = IVYIO_CreateEx_2(&url, "ABCDABCDABCDABCDABCD2222", "", "admin", "", IVYIO_P2P_MODE_UDP, IVYIO_P2P_MODE_A_TCP_V_UDP, IVYIO_DEV_FOS_DOORBELL, IVYIO_MAIN_VIDEO_STREAM);
11.2 Turn on doorbell video
- describe
Turn on doorbell video
IVYIO_RESULT IVYIO_API IVYIO_DoorBell_OpenVideo(IVYIO_HANDLE handle, int iTimeout)
- Parameters
handle | SDK handle |
---|---|
timeout | timeout period |
- return value
Operation result
- Remark
If you want to use the doorbell interface, you need to use IVYIO_CreateEx_2 to create a handle, and the device type is
IVYIO_DEV_FOS_DOORBELL, the creation function will immediately create 2 P2P to connect the device, one P2P for audio and one P2P for video. You can open the video directly without calling the login interface. If you need to call other interfaces other than the doorbell, this handle is valid and there is no need to recreate the handle. If the device type of the created handle interface is not a doorbell, the doorbell interface function cannot be used.
- Call example
//Create doorbell
IVYIO_URL url;
memset(&url, 0, sizeof(url));
strcpy(url.szUrl, "192.168.1.1");
url.usPort = 88;
IVYIO_HANDLE doorBellHandle = IVYIO_CreateEx_2(&url, "ABCDABCDABCDABCDABCDZZZZ", "", "admin", "", IVYIO_P2P_MODE_UDP, IVYIO_P2P_MODE_A_TCP_V_UDP, IVYIO_DEV_FOS_DOORBELL, IVYIO_MAIN_VIDEO_STREAM);
// You can open video after create handle
IVYIO_RESULT rst = IVYIO_DoorBell_OpenVideo(doorBellHandle, 1000 * 5);
11.3 Turn off doorbell video
- describe
Turn off doorbell video
IVYIO_RESULT IVYIO_API IVYIO_DoorBell_CloseVideo(IVYIO_HANDLE handle, int iTimeout)
- Parameters
handle | SDK handle |
---|---|
timeout | timeout period |
- return value
Operation result
- Call example
IVYIO_RESULT rst = IVYIO_DoorBell_CloseVideo(doorBellHandle, 1000 * 5);
11.4 Turn on doorbell audio
- describe
Turn on doorbell audio
IVYIO_RESULT IVYIO_API IVYIO_DoorBell_OpenAudio(IVYIO_HANDLE handle, int iTimeout)
- Parameters
handle | SDK handle |
---|---|
timeout | timeout period |
- return value
Operation result
- Call example
IVYIO_RESULT rst = IVYIO_DoorBell_OpenVideo(doorBellHandle, 1000 * 5);
if (IVYIO_RESULT_OK == rst)
rst = IVYIO_DoorBell_OpenAudio(doorBellHandle, 1000 * 5); // Or open audio in another thread
11.5 Turn off doorbell audio
- describe
Turn off doorbell audio
IVYIO_RESULT IVYIO_API IVYIO_DoorBell_CloseAudio(IVYIO_HANDLE handle, int iTimeout)
- Parameters
handle | SDK handle |
---|---|
timeout | timeout period |
- return value
Operation result
- Call example
IVYIO_DoorBell_CloseAudio(doorBellHandle, 1000 * 5);
11.6 Turn on doorbell intercom
- describe
Turn on doorbell intercom
IVYIO_RESULT IVYIO_API IVYIO_DoorBell_OpenTalk(IVYIO_HANDLE handle, int iTimeout)
- Parameters
handle | SDK handle |
---|---|
timeout | timeout period |
- return value
Operation result
- Remark
You need to call to open the audio interface first
- Call example
IVYIO_RESULT rst = IVYIO_DoorBell_OpenTalk(doorBellHandle, 1000 * 5);
11.7 Turn off the doorbell intercom
- describe
Turn off doorbell intercom
IVYIO_RESULT IVYIO_API IVYIO_DoorBell_CloseTalk(IVYIO_HANDLE handle, int iTimeout)
- Parameters
handle | SDK handle |
---|---|
timeout | timeout period |
- return value
Operation result
- Call example
IVYIO_RESULT rst = IVYIO_DoorBell_CloseTalk(doorBellHandle, 1000 * 5);
11.8 Send intercom data to the doorbell
- describe
Send doorbell intercom data
IVYIO_RESULT IVYIO_API IVYIO_DoorBell_SendTalkData(IVYIO_HANDLE handle, char *data, int dataLen)
- Parameters
handle | SDK handle |
---|---|
data | intercom data |
dataLen | Intercom data length |
- return value
Operation result
- Remark
The data sampling rate is 8000, which is generally 960 bytes in size.
- Call example
while(bGetData)
{
// Get talk data into talkData buffer.
IVYIO_DoorBell_SendTalkData(doorBellHandle, talkData, 960);
}
11.9 Get doorbell data (decoded)
- describe
Get the audio and video data decoded by the doorbell
IVYIO_RESULT IVYIO_API IVYIO_DoorBell_GetStreamData(IVYIO_HANDLE handle,
IVYIO_STREAM_TYPE stream,
unsigned char **data,
int *iOutLen,
int *iSpeed,
int iDecodeFmt)
- Parameters
handle | SDK handle |
---|---|
stream | Stream type 0: video stream 1: audio stream |
data | Pointer to the IVYIO_FRAME pointer that stores the media data frame structure |
iOutLen | The length of the returned data |
iSpeed | Data Traffic |
iDecodeFmt | Media data decoding type IVYIO_DECODE_FMT, if audio is obtained, ignore this parameter |
- return value
Operation result
- Remark
Notes are the same as IVYIO_GetStreamData, you can refer to its API description
- Call example
if (IVYIO_DEV_FOS_DOORBELL == devType)
{
// Get video in a thread
while (bGetVideoRunning)
{
IVYIO_FRAME *frame = NULL;
int outLen = 0;
int speed = 0;
IVYIO_RESULT rst = IVYIO_DoorBell_GetStreamData(handle, IVYIO_STREAM_VIDEO, (unsigned char **)&frame, &outLen, &speed, IVYIO_DEC_TYPE_YUV420);
if (IVYIO_RESULT_OK == rst && frame->len > 0)
{
// Display frame->data
}
else
{
sleep(10); // Sleep 10ms
}
}
//Get audio in another thread
while (bGetAudioRunning)
{
IVYIO_FRAME *frame = NULL;
int outLen = 0;
int speed = 0;
IVYIO_RESULT rst = IVYIO_DoorBell_GetStreamData(handle, IVYIO_STREAM_AUDIO, (unsigned char **)&frame, &outLen, &speed, IVYIO_DEC_TYPE_PCM);
if (IVYIO_RESULT_OK == rst && frame->len > 0)
{
// Display frame->data
}
else
{
sleep(10); // Sleep 10ms
}
}
}
11.10 Get doorbell data (not decoded)
- describe
Obtain the original audio and video data of the doorbell
IVYIO_RESULT IVYIO_API IVYIO_DoorBell_GetRawStreamData(IVYIO_HANDLE handle,
IVYIO_STREAM_TYPE stream,
unsigned char **data,
int *iOutLen,
int *iSpeed)
- Parameters
handle | SDK handle |
---|---|
stream | Stream type 0: video stream 1: audio stream |
data | Pointer to the IVYIO_FRAME pointer that stores the media data frame structure |
iOutLen | The length of the returned data |
iSpeed | Data Traffic |
- return value
Operation result
- Remark
Notes are the same as IVYIO_GetRawStreamData
- Call example
if (IVYIO_DEV_FOS_DOORBELL == devType)
{
// Get video in a thread
while (bGetVideoRunning)
{
IVYIO_FRAME *frame = NULL;
int outLen = 0;
int speed = 0;
IVYIO_RESULT rst = IVYIO_DoorBell_GetRawStreamData(handle, IVYIO_STREAM_VIDEO, (unsigned char **)&frame, &outLen, &speed);
if (IVYIO_RESULT_OK == rst && frame->len > 0)
{
// Display frame->data
}
else
{
sleep(10); // Sleep 10ms
}
}
// Get audio in another thread
while (bGetAudioRunning)
{
IVYIO_FRAME *frame = NULL;
int outLen = 0;
int speed = 0;
IVYIO_RESULT rst = IVYIO_DoorBell_GetRawStreamData(handle, IVYIO_STREAM_AUDIO, (unsigned char **)&frame, &outLen, &speed);
if (IVYIO_RESULT_OK == rst && frame->len > 0)
{
// Display frame->data
}
else
{
sleep(10); // Sleep 10ms
}
}
}
11.11 Doorbell local recording starts
- describe
Doorbell local recording starts
IVYIO_RESULT IVYIO_API IVYIO_DoorBell_StartRecord(IVYIO_HANDLE handle, IVYIO_RECORD_TYPE type, const char *szFileName)
- Parameters
handle | SDK handle |
---|---|
type | Video type 1: MP4 |
szFileName | The complete path name of the saved file |
- return value
Operation result
- Call example
if (IVYIO_DEV_FOS_DOORBELL == devType)
{
#ifdef _WIN32
IVYIO_DoorBell_StartRecord(doorBellHandle, IVYIO_RECORD_MP4, "c:\\record.mp4");
#else
IVYIO_DoorBell_StartRecord(doorBellHandle, IVYIO_RECORD_MP4, "/mydir/ecord.mp4");
#endif
}
11.12 Doorbell local recording ends
- describe
Doorbell local video recording ends
IVYIO_RESULT IVYIO_API IVYIO_DoorBell_StopRecord(IVYIO_HANDLE handle)
- Parameters
handle | SDK handle |
---|
- return value
Operation result
- Call example
if (IVYIO_DEV_FOS_DOORBELL == devType)
{
IVYIO_DoorBell_StopRecord(doorBellHandle);
}
11.13 Detect doorbell handle status
- describe
Detect the status of the doorbell handle. If any of the sockets or channels involved in the doorbell changes, an event will be generated.
IVYIO_HANDLE_STATE IVYIO_API IVYIO_DoorBell_CheckHandle(IVYIO_HANDLE handle)
- Parameters
handle | SDK handle |
---|
return value
doorbell handle statusCall example
if (IVYIO_DEV_FOS_DOORBELL == devType)
{
while(bChecking)
{
IVYIO_HANDLE_STATE state = IVYIO_DoorBell_CheckHandle(doorBellHandle);
//handle state
.....
}
}
11.14 Get doorbell events
- describe
Get doorbell events
IVYIO_RESULT IVYIO_API IVYIO_DoorBell_GetEvent(IVYIO_HANDLE handle, IVYIO_EVENT *event)
- Parameters
handle | SDK handle |
---|---|
event | event |
- return value
Operation result
- Call example
if (IVYIO_DEV_FOS_DOORBELL == devType)
{
while(bChecking)
{
IVYIO_EVENT event;
memset(&event, 0, sizeof(event));
if (IVYIO_RESULT_OK == IVYIO_DoorBell_GetEvent(doorBellHandle))
{
switch(event.id)
{
case NET_STATE_DISCONNECT:
// Handle function
break;
case......
break;
...
default:
break;
}
}
}
}
11.15 Set OpenTalk intercom flag (only applicable on iOS platform)
- describe
Set the OpenTalk intercom flag. After the setting is completed, the device will have some special processing when playing sound. Currently, this interface is only for iOS.
void IVYIO_API IVYIO_SetOpenTalkFlag(IVYIO_HANDLE handle, int flag)
- Parameters
handle | SDK handle |
---|---|
flag | 0 / 1 |
- return value
Operation result
- Remark
The echo cancellation problem of iOS is that the sound that has been eliminated by iOS will become relatively small when it reaches the IPC. After setting this table, the device will know that it is iOS based on this indication and will increase the playback volume. This command is only valid for Foscam devices.
- Call example
if (IVYIO_DEV_FOS_DOORBELL == devType)
{
IVYIO_SetOpenTalkFlag(doorBellHandle, 1);
}
11.16 Doorbell answering status query
- describe
Get the doorbell answering status, whether it has been answered by another device
IVYIO_RESULT IVYIO_API IVYIO_DoorBell_QueryAnswerState(IVYIO_HANDLE handle, int *state, int iTimeout)
- Parameters
handle | SDK handle |
---|---|
state | Status, 2: Not answered 0: Already answered 3: The current call is rejected by the app 4: ipc actively cancels the call 5: ipc actively hangs up -1: If the current APP has answered the device, the device will return this value |
iTimeout | timeout |
- return value
Operation result
- Remark
Only doorbell devices are supported. You must call IVYIO_DoorBell_OpenVideo successfully before calling this interface, otherwise the status cannot be found correctly.
Because only when IVYIO_DoorBell_OpenVideo succeeds, the device will be authenticated and have a password, so that the SDK can correctly obtain the data. Subsequent devices may update the firmware to solve the problem that must be called after IVYIO_DoorBell_OpenVideo.
- Call example
if (IVYIO_DEV_FOS_DOORBELL == devType)
{
while(bChecking)
{
int state = -1;
if (IVYIO_RESULT_OK == IVYIO_DoorBell_QueryAnswerState(doorBellHandle, &state, 1000 * 5))
{
if (0 == state)
...
else if (1 == state)
...
else
...
}
}
}
12 Get image interface (only supports IVY devices)
12.1 Get image list
- describe
Get picture list
Image information supports multiple data structures, which are distinguished according to capability sets. Bit4 in val6, if the bit is 1, it means direction/weight is supported, you can refer to ‘Call Example 2’, if the bit is 0, ‘Reference Example 1’
IVYIO_RESULT IVYIO_API IVYIO_GetPictureList(IVYIO_HANDLE handle, void *args, void *list, int iTimeout, int iChannel)
- Parameters
handle | SDK handle |
---|---|
args | Pointer to IVYIO_PICTURE_SEARCH structure |
list | Pointer to IVYIO_PICTURE_LIST or IVYIO_PICTURE_LIST_EX structure |
iTimeout | timeout |
iChannel | Channel number, same as opening video |
- return value
Operation result
- Quote
// Picture download
typedef struct _IVYIO_PICTURE_SEARCH_
{
int sln; // must be 0 or 1
unsigned long long sTime; // start timestamp, unit second
unsigned long long eTime; // end timestamp, unit second
int type; // type, same as "IVYIO_GetPlaybackRecordList" record type
unsigned int startNo; // Start NO
int count; // Count of search, max 20
}ATTRIBUTE_PACKED IVYIO_PICTURE_SEARCH, *PIVYIO_PICTURE_SEARCH;
typedef struct _IVYIO_PICTURE_INFO_
{
int format; // Picture format, only supports JPEG, value is 200
unsigned long long time; // Timestamp
unsigned int type; // Picture type same as "IVYIO_GetPlaybackRecordList" record type
}ATTRIBUTE_PACKED IVYIO_PICTURE_INFO, *PIVYIO_PICTURE_INFO;
typedef struct _IVYIO_PICTURE_LIST_
{
int channel; // channel
unsigned int totalCount; // Total count
unsigned int curCount; // Current search count
IVYIO_PICTURE_INFO list[20];
}ATTRIBUTE_PACKED IVYIO_PICTURE_LIST, *PIVYIO_PICTURE_LIST;
typedef struct _IVYIO_PICTURE_INFO_EX_
{
int direction;
int weight;
}ATTRIBUTE_PACKED IVYIO_PICTURE_INFO_EX, *PIVYIO_PICTURE_INFO_EX;
typedef struct _IVYIO_PICTURE_LIST_EX_
{
int channel;
unsigned int totalCount;
unsigned int curCount;
IVYIO_PICTURE_INFO list[20];
IVYIO_PICTURE_INFO listEx[20];
}ATTRIBUTE_PACKED IVYIO_PICTURE_LIST_EX, *PIVYIO_PICTURE_LIST_EX;
- Remark
iChanel currently please pass 0 or 1.
- Call example 1
// sln = 0
if (IVYIO_DEV_IPC == devType)
{
IVYIO_PICTURE_SEARCH ips;
memset(&ips, 0, sizeof(IVYIO_PICTURE_SEARCH));
ips.sTime = 1620316800; // 2021-05-07 00:00:00 (beijing)
ips.eTime = 1620403199; // 2021-05-07 23:59:59 (beijing)
ips.sln = 0;
ips.count = 20;
ips.startNo = startNo;
IVYIO_PICTURE_LIST ipl;
memset(&ipl, 0, sizeof(IVYIO_PICTURE_LIST));
int size = sizeof(IVYIO_PICTURE_LIST);
rst = IVYIO_GetPictureList(m_handle, (void *)&ips, (void *)&ipl, 1000 * 10, 0);
if (rst != IVYIO_RESULT_OK)
{
return;
}
}
- Call Example 2
// sln = 1
//support direction/weight
if (IVYIO_DEV_IPC == devType)
{
IVYIO_PICTURE_SEARCH ips;
memset(&ips, 0, sizeof(IVYIO_PICTURE_SEARCH));
ips.sTime = 1620316800; // 2021-05-07 00:00:00 (beijing)
ips.eTime = 1620403199; // 2021-05-07 23:59:59 (beijing)
ips.sln = 1;
ips.count = 20;
ips.startNo = startNo;
IVYIO_PICTURE_LIST_EX ipl;
memset(&ipl, 0, sizeof(IVYIO_PICTURE_LIST_EX));
int size = sizeof(IVYIO_PICTURE_LIST_EX);
rst = IVYIO_GetPictureList(m_handle, (void *)&ips, (void *)&ipl, 1000 * 10, 0);
if (rst != IVYIO_RESULT_OK)
{
return;
}
}
12.2 Get image data
- describe
Get image data
If the capability is set to bit4 in val6, if the bit is 1, you need to use the IVYIO_GET_MULTI_PICTURE_EX structure to request the picture, refer to ‘Call Example 1’, if the bit is 0, use the IVYIO_GET_MULTI_PICTURE structure, refer to ‘Call Example 2’
IVYIO_RESULT IVYIO_API IVYIO_GetPicture(IVYIO_HANDLE handle, void *args, void *files[20], int *fileCount, int iTimeout, int iChannel)
- Parameters
handle | SDK handle |
---|---|
args | Pointer to IVYIO_GET_MULTI_PICTURE or IVYIO_GET_MULTI_PICTURE_EX structure |
files | Pointer array, storing up to 20 picture information, the pointer structure is IVYIO_PICTURE_FILE |
fileCount | Actual number of downloaded pictures |
iTimeout | timeout |
iChannel | Channel number, 0-31, only one channel’s pictures can be obtained at a time, currently only channel 0 is supported |
- return value
Operation result
- Quote
// Picture information
typedef struct _IVYIO_GET_PICTURE_
{
int format; // picture format, value is 200, JPEG format
int type; // picture type, same as type in IVYIO_PICTURE_INFO structure
unsigned long long time; // picture timestamp.
}ATTRIBUTE_PACKED IVYIO_GET_PICTURE, *PIVYIO_GET_PICTURE;
typedef struct _IVYIO_GET_MULTI_PICTURE_EX_
{
int sln; // must be 1
int countOfUsed; // Can be used picture array count
IVYIO_PICTURE_INFO picture[20]; // max size 20
IVYIO_PICTURE_INFO_EX pictureEx[20]; // max size 20
}ATTRIBUTE_PACKED IVYIO_GET_MULTI_PICTURE_EX, *PIVYIO_GET_MULTI_PICTURE_EX;
//Multi-picture information to request
typedef struct _IVYIO_GET_MULTI_PICTURE_
{
int sln; // must be 0
int countOfUsed; // Can be used picture array count
IVYIO_GET_PICTURE picture[20]; // max size 20
}ATTRIBUTE_PACKED IVYIO_GET_MULTI_PICTURE, *PIVYIO_GET_MULTI_PICTURE;
// Picture data
typedef struct _IVYIO_PICTURE_FILE_
{
int channel; // Channel
int format; // Picture format, same as type in IVYIO_GET_PICTURE structure
int type; // Picture type, same as type in IVYIO_GET_PICTURE structure
unsigned long long time; // Timestamp
unsigned int size; // Picture data size
char data[0]; // Picture data
}ATTRIBUTE_PACKED IVYIO_PICTURE_FILE, *PIVYIO_PICTURE_FILE;
- Remark
iChanel currently please pass 0; files is an array of pointers, apply for a piece of memory for each element, and then use the IVYIO_PICTURE_FILE structure pointer to access each memory separately.
- Call example 1
if (IVYIO_DEV_IPC == devType)
{
IVYIO_PICTURE_LIST ipl;
memset(&ipl, 0, sizeof(IVYIO_PICTURE_LIST));
// Get picture list
...
IVYIO_GET_MULTI_PICTURE *request = new IVYIO_GET_MULTI_PICTURE();
request->sln = 0;
request->countOfUsed = 2;
request->picture[0].time = ipl.list[0].time;
request->picture[0].type = ipl.list[0].type;
request->picture[0].format = ipl.list[0].format;
request->picture[1].time = ipl.list[1].time;
request->picture[1].type = ipl.list[1].type;
request->picture[1].format = ipl.list[1].format;
// Pictures memory
void *buffer[20];
for (int i = 0; i < 20; i++)
{
buffer[i] = new char[1024 * 1024];
memset(buffer[i], 0, 1024 * 1024);
}
int pictureCount = 0;
IVYIO_RESULT rst = IVYIO_GetPicture(handle, (void *)request, buffer, &pictureCount, 1000 * 10, 0);
if (IVYIO_RESULT_OK == rst)
{
int len = 0;
char szText[1024] = {0};
for (int i = 0; i < pictureCount; i++)
{
IVYIO_PICTURE_FILE *pictureFile = (IVYIO_PICTURE_FILE *)buffer[i];
if (pictureFile->size > 0)
{
// Picture data in pictureFile->data
}
}
}
}
- Call Example 2
if (IVYIO_DEV_IPC == devType)
{
IVYIO_PICTURE_LIST_EX ipl;
memset(&ipl, 0, sizeof(IVYIO_PICTURE_LIST_EX));
// Get picture listex
...
IVYIO_GET_MULTI_PICTURE_EX *request = new IVYIO_GET_MULTI_PICTURE_EX();
request->sln = 1;
request->countOfUsed = 2;
request->picture[0].time = ipl.list[0].time;
request->picture[0].type = ipl.list[0].type;
request->picture[0].format = ipl.list[0].format;
request->picture[1].time = ipl.list[1].time;
request->picture[1].type = ipl.list[1].type;
request->picture[1].format = ipl.list[1].format;
request->pictureEx[0].direction = ipl.list[0].direction;
request->pictureEx[0].weight = ipl.list[0].weight;
request->pictureEx[1].direction = ipl.list[1].direction;
request->pictureEx[1].weight = ipl.list[1].weight;
// Pictures memory
void *buffer[20];
for (int i = 0; i < 20; i++)
{
buffer[i] = new char[1024 * 1024];
memset(buffer[i], 0, 1024 * 1024);
}
int pictureCount = 0;
IVYIO_RESULT rst = IVYIO_GetPicture(handle, (void *)request, buffer, &pictureCount, 1000 * 10, 0);
if (IVYIO_RESULT_OK == rst)
{
int len = 0;
char szText[1024] = {0};
for (int i = 0; i < pictureCount; i++)
{
IVYIO_PICTURE_FILE *pictureFile = (IVYIO_PICTURE_FILE *)buffer[i];
if (pictureFile->size > 0)
{
// Picture data in pictureFile->data
}
}
}
}
13. RTSP API (non-thread safe)
13.1 Turn on RTSP
- describe
Open an RTSP instance based on the URL
void * IVYIO_RTSP_Open(const char *url)
- Parameters
url | url address |
---|
- return value
The void pointer is actually an RTSP instance address.
If opening RTSP fails, return NULL.
- Remark
Hikvision device URL address is rtsp://admin:123456@192.168.1.68:554/Streaming/Channels
- Call example
void *rtsp = IVYIO_RTSP_Open("rtsp://admin:123456@192.168.1.68:554/Streaming/Channels");
13.2 Turn off RTSP
- describe
Turn off RTSP
int IVYIO_RTSP_Close(void *inst);
- Parameters
inst | instance address |
---|
- return value
0 is success, other values are failure
- Call example
void *rtsp = IVYIO_RTSP_Open("rtsp://admin:123456@192.168.1.68:554/Streaming/Channels");
...
IVYIO_RTSP_Close(rtsp);
13.3 Get RTSP stream (original video + PCM audio)
- describe
Get the RTSP stream (including video and audio, the video is the original video, and the audio is the decoded PCM)
int IVYIO_RTSP_GetRawFrameAndPCM(void *inst, unsigned char **frame, int *frameSize, IVYIO_RTSP_VIDEO_INFO *videoinfo, IVYIO_RTSP_AUDIO_INFO *audioInfo, int *audioOrVideo);
- Parameters
inst | instance address |
---|---|
frame | pointer to stream data pointer |
frameSize | stream data size |
videoinfo | Current video stream information, refer to IVYIO_RTSP_VIDEO_INFO |
audioInfo | Current audio stream information, refer to IVYIO_RTSP_AUDIO_INFO |
audioOrVideo | Video audio flag, refer to IVYIO_RTSP_FRAME_TYPE |
- return value
0 is success, other values are failure
- Call example
unsigned char *frame = NULL;
int size = 0;
int frameType = 0;
IVYIO_RTSP_VIDEO_INFO v;
IVYIO_RTSP_AUDIO_INFO a;
memset(&v, 0, sizeof(v));
memset(&a, 0, sizeof(a));
if (0 == IVYIO_RTSP_GetRawFrameAndPCM(rtsp, &frame, &size, &v, &a, &frameType))
{
//get data ok!
}
- Quote
typedef struct _IVYIO_RTSP_VIDEO_INFO_
{
int w;
int h;
int key;
int fmt; // see IVYIO_RTSP_CODEC_ID
}ATTRIBUTE_PACKED IVYIO_RTSP_VIDEO_INFO, *PIVYIO_RTSP_VIDEO_INFO;
typedef struct _IVYIO_RTSP_AUDIO_INFO_
{
int codecId;
int sampleRate;
int sampleFmt; // see IVYIO_RTSP_SAMPLE_FMT
int channels;
int channelLayout;
}ATTRIBUTE_PACKED IVYIO_RTSP_AUDIO_INFO, *PIVYIO_RTSP_AUDIO_INFO;
typedef enum
{
IVYIO_RTSP_CODEC_ID_UNKNOWN = -1,
IVYIO_RTSP_CODEC_ID_H264 = 0,
IVYIO_RTSP_CODEC_ID_HEVC = 1,
IVYIO_RTSP_CODEC_ID_AAC = 2,
IVYIO_RTSP_CODEC_ID_PCM = 3,
IVYIO_RTSP_CODEC_ID_PCM_MULOW = 4,
IVYIO_RTSP_CODEC_ID_PCM_ALOW = 5
} IVYIO_RTSP_CODEC_ID;
typedef enum
{
IVYIO_RTSP_SAMPLE_FMT_UNKNOWN = -1,
IVYIO_RTSP_SAMPLE_FMT_S16 = 1
} IVYIO_RTSP_SAMPLE_FMT;
typedef enum
{
IVYIO_RTSP_FRAME_VIDEO = 0,
IVYIO_RTSP_FRAME_AUDIO = 1
} IVYIO_RTSP_FRAME_TYPE;
13.4 Get RTSP stream (decoded video + PCM audio)
- describe
Get the RTSP stream (including video and audio, the video is the decoded video, and the audio is the decoded PCM)
int IVYIO_RTSP_GetFrame(void *inst, unsigned char **frame, int *frameSize, IVYIO_RTSP_VIDEO_INFO *videoinfo, IVYIO_RTSP_AUDIO_INFO *audioInfo, int *audioOrVideo, int videoDecodeFmt);
- Parameters
inst | instance address |
---|---|
frame | pointer to stream data pointer |
frameSize | stream data size |
videoinfo | Current video stream information, refer to IVYIO_RTSP_VIDEO_INFO |
audioInfo | Current audio stream information, refer to IVYIO_RTSP_AUDIO_INFO |
audioOrVideo | Video audio flag, refer to IVYIO_RTSP_FRAME_TYPE |
videoDecodeFmt | Video decoding format, refer to IVYIO_DECODE_FORMAT |
- return value
0 is success, other values are failure
- Call example
unsigned char *frame = NULL;
int size = 0;
int frameType = 0;
IVYIO_RTSP_VIDEO_INFO v;
IVYIO_RTSP_AUDIO_INFO a;
memset(&v, 0, sizeof(v));
memset(&a, 0, sizeof(a));
if (0 == IVYIO_RTSP_GetFrame(rtsp, &frame, &size, &v, &a, &frameType, IVYIO_DEC_TYPE_UYVY422))
{
//get data ok!
}
- Quote
typedef struct _IVYIO_RTSP_VIDEO_INFO_
{
int w;
int h;
int key;
int fmt; // see IVYIO_RTSP_CODEC_ID
}ATTRIBUTE_PACKED IVYIO_RTSP_VIDEO_INFO, *PIVYIO_RTSP_VIDEO_INFO;
typedef struct _IVYIO_RTSP_AUDIO_INFO_
{
int codecId;
int sampleRate;
int sampleFmt; // see IVYIO_RTSP_SAMPLE_FMT
int channels;
int channelLayout;
}ATTRIBUTE_PACKED IVYIO_RTSP_AUDIO_INFO, *PIVYIO_RTSP_AUDIO_INFO;
typedef enum
{
IVYIO_RTSP_CODEC_ID_UNKNOWN = -1,
IVYIO_RTSP_CODEC_ID_H264 = 0,
IVYIO_RTSP_CODEC_ID_HEVC = 1,
IVYIO_RTSP_CODEC_ID_AAC = 2,
IVYIO_RTSP_CODEC_ID_PCM = 3,
IVYIO_RTSP_CODEC_ID_PCM_MULOW = 4,
IVYIO_RTSP_CODEC_ID_PCM_ALOW = 5
} IVYIO_RTSP_CODEC_ID;
typedef enum
{
IVYIO_RTSP_SAMPLE_FMT_UNKNOWN = -1,
IVYIO_RTSP_SAMPLE_FMT_S16 = 1
} IVYIO_RTSP_SAMPLE_FMT;
typedef enum
{
IVYIO_RTSP_FRAME_VIDEO = 0,
IVYIO_RTSP_FRAME_AUDIO = 1
} IVYIO_RTSP_FRAME_TYPE;
typedef enum
{
IVYIO_DECODE_VIDEORAW,
IVYIO_DECODE_ARGB32, //packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
IVYIO_DECODE_RGBA32, //packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
IVYIO_DECODE_ABGR32, //packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
IVYIO_DECODE_BGRA32, //packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
IVYIO_DECODE_RGB24, //packed RGB 8:8:8, 24bpp, RGBRGB...
IVYIO_DECODE_BGR24, //packed RGB 8:8:8, 24bpp, BGRBGR...
IVYIO_DECODE_RGB565BE, //packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
IVYIO_DECODE_RGB565LE, //packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
IVYIO_DECODE_BGR565BE, //packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian
IVYIO_DECODE_BGR565LE, //packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian
IVYIO_DECODE_YUV420,
IVYIO_DECODE_YUYV422,
IVYIO_DECODE_UYVY422,
IVYIO_DECODE_H264,
IVYIO_DECODE_MJPEG,
IVYIO_DECODE_MJPEG_BASE64,
IVYIO_DECODE_H264_BASE64,
IVYIO_DECODE_AUDIORAW,
IVYIO_DECODE_G726,
IVYIO_DECODE_G711U,
IVYIO_DECODE_PCM,
IVYIO_DECODE_ADPCM,
IVYIO_DECODE_G711A,
IVYIO_DECODE_AAC,
IVYIO_DECODE_HEVC
} IVYIO_DECODE_FORMAT;
14. Two-way video
14.1 Turn on two-way video
- describe
Turn on two-way video and tell the device to send audio and video data to it
IVYIO_RESULT IVYIO_API IVYIO_OpenSendLive(IVYIO_HANDLE handle, int op, int timeout);
- Parameters
handle | SDK handle |
---|---|
op | The media type to be sent. Bitwise representation bit0:video bit1:audio |
timeout | timeout, unit ms |
- return value
Reference IVYIO_RESULT
- Remark
- Call example
// Create SDK handle for IVY two-way-video IPC with main stream video
IVYIO_URL url;
memset(&url, 0, sizeof(url));
strcpy(url.szUrl, "192.168.1.1");
url.usPort = 88;
IVYIO_HANDLE handle = IVYIO_CreateEx_1(&url, "ABCDABCDABCDABCDABCD2222", "", "admin", "", IVYIO_P2P_MODE_UDP, IVYIO_DEV_TWO_WAY_VIDEO_CAMERA, IVYIO_MAIN_VIDEO_STREAM);
IVYIO_RESULT rst = IVYIO_OpenSendLive(handle, IVYIO_LIVE_CALL_VIDEO | IVYIO_LIVE_CALL_AUDIO, 1000 * 20);
14.2 Turn off two-way video
- describe
Turn off two-way video and tell the device to turn off sending audio and video data
IVYIO_RESULT IVYIO_API IVYIO_CloseSendLive(IVYIO_HANDLE handle, int op, int timeout);
- Parameters
handle | SDK handle |
---|---|
op | The media type to be sent. Bitwise representation bit0:video bit1:audio |
timeout | timeout, unit ms |
- return value
Reference IVYIO_RESULT
- Call example
//......
IVYIO_RESULT rst = IVYIO_CloseSendLive(handle, IVYIO_LIVE_CALL_VIDEO | IVYIO_LIVE_CALL_AUDIO, 1000 * 20);
//......
14.3 Send video
- describe
To send a video, put the video into the SDK buffer and the SDK will automatically send it.
IVYIO_RESULT IVYIO_API IVYIO_SendVideo(IVYIO_HANDLE handle, char *frame, int len);
- Parameters
handle | SDK handle |
---|---|
frame | Memory to store IVYIO_FRAME structure |
len | The size of the memory storing the IVYIO_FRAME structure |
- return value
Reference IVYIO_RESULT
- Remark
If the buffer cannot fit the video data, the SDK will discard the video. The buffer size is 3M
- Call example
// videodata is one h264 frame
// videodataSize is frame len
char *buffer = new char[1024 * 1024];
IVYIO_FRAME *videoFrame = (IVYIO_FRAME *)buffer;
videoFrame->channel = 0;
videoFrame->iKey = 1;
videoFrame->index = index++;
videoFrame->len = videodataSize;
videoFrame->pts = index;
videoFrame->media.video.w = 1280;
videoFrame->media.video.h = 960;
videoFrame->media.video.bitRate = 26000;
videoFrame->media.video.frameRate = 25;
videoFrame->fmt = IVYIO_STREAM_H264;
videoFrame->type = IVYIO_STREAM_VIDEO;
memcpy(videoFrame->data, videodata, videodataSize);
rst = IVYIO_SendVideo(handle, buffer, videoFrame->len + sizeof(IVYIO_FRAME));
14.4 Send audio
- describe
Send audio, put the audio into the SDK buffer, and the SDK will automatically send it
IVYIO_RESULT IVYIO_API IVYIO_SendAudio(IVYIO_HANDLE handle, char *frame, int len);
- Parameters
handle | SDK handle |
---|---|
frame | Memory to store IVYIO_FRAME structure |
len | The size of the memory storing the IVYIO_FRAME structure |
- return value
Reference IVYIO_RESULT
- Remark
If the buffer cannot fit the audio data, the SDK will discard the audio. Buffer size is 128KB
- Call example
// audiodata is one package
char *buffer = new char[1024 * 1024];
IVYIO_FRAME *audioFrame = (IVYIO_FRAME *)buffer;
audioFrame->channel = 0;
audioFrame->iKey = 1;
audioFrame->index = index++;
audioFrame->len = 960;
audioFrame->pts = index;
audioFrame->media.audio.bitsPerSample = 16;
audioFrame->media.audio.channels = 2;
audioFrame->media.audio.sample = 8000;
audioFrame->fmt = IVYIO_STREAM_PCM;
audioFrame->type = IVYIO_STREAM_AUDIO;
memcpy(audioFrame->data, audiodata, 960);
rst = IVYIO_SendVideo(handle, buffer, audioFrame->len + sizeof(IVYIO_FRAME));
14.5 Reject Video
- describe
Tell IPC that the current APP rejects the video
IVYIO_RESULT IVYIO_API IVYIO_RejectVideoCall(IVYIO_HANDLE handle, int timeout);
- Parameters
handle | SDK handle |
---|---|
timeout | timeout, unit ms |
- return value
Reference IVYIO_RESULT
- Call example
//......
IVYIO_RESULT rst = IVYIO_RejectVideoCall(handle, 1000 * 20);
//......
14.6 Get two-way video status
- describe
Get two-way video status
IVYIO_RESULT IVYIO_API IVYIO_GetVideoCallState(IVYIO_HANDLE handle, int *state, int timeout);
- Parameters
handle | SDK handle |
---|---|
state | (Call status: 0-idle, 1-calling, 2-calling |
timeout | timeout, unit ms |
- return value
Reference IVYIO_RESULT
- Call example
//......
int state = -1;
IVYIO_RESULT rst = IVYIO_GetVideoCallState(handle, &state, 1000 * 20);
//......