Network Clients

Table of Contents

Synopsis
Description
Details

Network Clients - support for network connection

Synopsis

#define ednet_client_destroy

typedef EDNetClient;

EDNetClient   *ednet_client_new                        (void);
void           ednet_client_ref                        (EDNetClient          *client);
void           ednet_client_unref                      (EDNetClient          *client);
int            ednet_client_add_hook                   (EDNetClient          *client,
                                                        EDNetLinkHookType     hook,
                                                        EDNetFunc             func,
                                                        void                 *data);
int            ednet_client_remove_hook                (EDNetClient          *client,
                                                        EDNetLinkHookType     hook,
                                                        EDNetFunc             func,
                                                        void                 *data);
EDNetLinkState ednet_client_get_state                  (EDNetClient          *client);
void           ednet_client_get_product                (EDNetClient          *client,
                                                        int                  *type,
                                                        int                  *id);
int            ednet_client_run                        (EDNetClient          *client,
                                                        int                   timeout);
int            ednet_client_main                       (EDNetClient          *client);
int            ednet_client_quit                       (EDNetClient          *client);
int            ednet_client_connect                    (EDNetClient          *client,
                                                        const char           *host,
                                                        int                   port,
                                                        const char           *user,
                                                        const char           *password);
int            ednet_client_shutdown                   (EDNetClient          *client);
int            ednet_client_request_channel_list       (EDNetClient          *client);
int            ednet_client_request_channel_properties (EDNetClient          *client,
                                                        int                   channel);
int            ednet_client_change_channel_property    (EDNetClient          *client,
                                                        int                   channel,
                                                        EDNetPropertyID       pid,
                                                        const char           *pstr,
                                                        int                   pval);
int            ednet_client_add_wanted_frame_format    (EDNetClient          *client,
                                                        int                   channel,
                                                        EDNetFrameFormat      fmt,
                                                        int                   width,
                                                        int                   height);
int            ednet_client_remove_wanted_frame_format (EDNetClient          *client,
                                                        int                   channel,
                                                        EDNetFrameFormat      fmt,
                                                        int                   width,
                                                        int                   height);
int            ednet_client_request_stream             (EDNetClient          *client,
                                                        int                   channel,
                                                        int                   request);
int            ednet_client_control_device             (EDNetClient          *client,
                                                        EDNetDeviceID         dev_id,
                                                        int                   dev_no,
                                                        EDNetDevicePTZCommand ptz);
int            ednet_client_phone                      (EDNetClient          *client,
                                                        EDNetPhoneCommand     cmd,
                                                        int                   src_channel,
                                                        int                   dest_channel,
                                                        int                   flags);
int            ednet_client_send_frame                 (EDNetClient          *client,
                                                        EDNetFrame           *frame);
int            ednet_client_send_channel_list          (EDNetClient          *client,
                                                        int                   total,
                                                        int                  *channels);
int            ednet_client_send_channel_property      (EDNetClient          *client,
                                                        int                   channel,
                                                        EDNetPropertyID       pid,
                                                        const char           *pstr,
                                                        int                   pval);
int            ednet_client_reply_stream               (EDNetClient          *client,
                                                        int                   channel,
                                                        int                   reply);
int            ednet_client_request_config             (EDNetClient          *client,
                                                        const char           *section,
                                                        const char           *key);
int            ednet_client_change_config              (EDNetClient          *client,
                                                        const char           *section,
                                                        const char           *key,
                                                        const char           *value);
int            ednet_client_request_dir                (EDNetClient          *client,
                                                        EDNetDirType          req_type,
                                                        unsigned int          req_id,
                                                        const char           *path);
int            ednet_client_request_mpeg_file_open     (EDNetClient          *client,
                                                        unsigned int          req_id,
                                                        unsigned int          file_id,
                                                        const char           *name);
int            ednet_client_request_mpeg_file_read     (EDNetClient          *client,
                                                        unsigned int          req_id,
                                                        unsigned int          file_id,
                                                        EDNetMpegFileReadType read_type);
int            ednet_client_request_mpeg_file_seek     (EDNetClient          *client,
                                                        unsigned int          req_id,
                                                        unsigned int          file_id,
                                                        unsigned int          idx,
                                                        EDNetMpegFileSeekFlag flag);
int            ednet_client_request_mpeg_file_close    (EDNetClient          *client,
                                                        unsigned int          req_id,
                                                        unsigned int          file_id);
int            ednet_client_request_file_transfer      (EDNetClient          *client,
                                                        unsigned int          req_id,
                                                        const char           *filename);
int            ednet_client_cancel_file_transfer       (EDNetClient          *client,
                                                        unsigned int          req_id);

Description

The EDNetClient is the core of EDNet SDK. All network transactions between a client and a DVR / NT server handled by this network client object.

You can order a client to control a remote server with ednet_client_*() functions. The video / audio frames and server informations received from remote servers can be notified by hooking network events with ednet_client_add_hook().

Multiple EDNetClient can be created and managed for control multiple servers simultaneously without no worry.

Details

ednet_client_destroy

#define ednet_client_destroy (client)          (client)

EDNetClient

typedef struct _EDNetClient EDNetClient;

A network client object to connect and control remote DVR / NT servers.

ednet_client_new ()

EDNetClient   *ednet_client_new                        (void);

Creates a new EDNetClient.

Returns :

a new EDNetClient, NULL if an error occurred.

ednet_client_ref ()

void           ednet_client_ref                        (EDNetClient          *client);

Adds a reference to the client.

client :

a EDNetClient

ednet_client_unref ()

void           ednet_client_unref                      (EDNetClient          *client);

Removes a reference from the client, deallocating the client if no references remain.

client :

a EDNetClient

ednet_client_add_hook ()

int            ednet_client_add_hook                   (EDNetClient          *client,
                                                        EDNetLinkHookType     hook,
                                                        EDNetFunc             func,
                                                        void                 *data);

Adds a hook function to be called when specified hook type occur. User data will be passed as the last parameter of the hook function.

Several hook functions can be added to the same hook type.

Hook functions are called within a thread in which the library executes, by calling ednet_client_run() or ednet_client_main().

client :

a EDNetClient

hook :

hook type

func :

callback function

data :

user data

Returns :

0 on success, -1 if an error occurred.

ednet_client_remove_hook ()

int            ednet_client_remove_hook                (EDNetClient          *client,
                                                        EDNetLinkHookType     hook,
                                                        EDNetFunc             func,
                                                        void                 *data);

Removes a hook function for the hook type which has added with user data.

client :

a EDNetClient

hook :

hook type

func :

callback function

data :

user data

Returns :

0 on success, -1 if an error occurred.

ednet_client_get_state ()

EDNetLinkState ednet_client_get_state                  (EDNetClient          *client);

Returns the state of the client.

client :

a EDNetClient

Returns :

current state, see EDNetLinkState

ednet_client_get_product ()

void           ednet_client_get_product                (EDNetClient          *client,
                                                        int                  *type,
                                                        int                  *id);

Returns product information about the connected server.

client :

a EDNetClient

type :

a pointer to store product type

id :

a pointer to store product id

ednet_client_run ()

int            ednet_client_run                        (EDNetClient          *client,
                                                        int                   timeout);

Runs the main loop to process network transaction and application requests for a time.

client :

a EDNetClient

timeout :

an upper limit on the time for which it will block, in milliseconds. Specifying a negative value means an infinite timeout.

Returns :

0 on success, -1 if an error occurred.

ednet_client_main ()

int            ednet_client_main                       (EDNetClient          *client);

Runs the main loop to process network transaction and application requests until ednet_client_quit() is called.

If you want to manage network processing in a seperated thread, this function may be suitable for that situation.

client :

a EDNetClient

Returns :

0 on success, -1 if an error occurred.

ednet_client_quit ()

int            ednet_client_quit                       (EDNetClient          *client);

Makes the invocation of the main loop return.

This function can be called within other threads in which the main loop is running.

client :

a EDNetClient

Returns :

0 on success, -1 if an error occurred.

ednet_client_connect ()

int            ednet_client_connect                    (EDNetClient          *client,
                                                        const char           *host,
                                                        int                   port,
                                                        const char           *user,
                                                        const char           *password);

Starts connecting to the remote DVR / NT server.

The result of connection is returned via EDNET_EVENT_CONNECT_REPLY event within EDNET_LINK_HOOK_EVENT hook. If the connection is established, the state of the client is changed to EDNET_LINK_STATE_ONLINE. You can also track client's state with EDNET_LINK_HOOK_STATE hook.

client :

a EDNetClient

host :

host address

port :

port number, use default 8081 if this value is zero.

user :

user name

password :

password

Returns :

0 on normal condition, 1 if it's not off-line state.

ednet_client_shutdown ()

int            ednet_client_shutdown                   (EDNetClient          *client);

Disconnects the connection from the remote DVR / NT server.

The result of a shutdown is returned via EDNET_EVENT_SHUTDOWN_REPLY event within EDNET_LINK_HOOK_EVENT hook.

client :

a EDNetClient

Returns :

0 on normal condition, -1 if a error occurred.

ednet_client_request_channel_list ()

int            ednet_client_request_channel_list       (EDNetClient          *client);

Requests the server to retrieve the list of channels.

The result is returned via EDNET_EVENT_CHANNEL_LIST event within EDNET_LINK_HOOK_EVENT hook.

Note that EDNET_EVENT_CHANNEL_LIST event is signaled automatically after the connection is established.

client :

a EDNetClient

Returns :

0 on success, -1 if a error occurred.

ednet_client_request_channel_properties ()

int            ednet_client_request_channel_properties (EDNetClient          *client,
                                                        int                   channel);

Requests the server to retrieve the properties of channels.

The result is returned via EDNET_EVENT_CHANNEL_PROPERTY event within EDNET_LINK_HOOK_EVENT hook.

Note that EDNET_EVENT_CHANNEL_PROPERTY events for all channels are signaled automatically after the connection is established.

client :

a EDNetClient

channel :

channel number, -1 means all channels.

Returns :

0 on success, -1 if a error occurred.

ednet_client_change_channel_property ()

int            ednet_client_change_channel_property    (EDNetClient          *client,
                                                        int                   channel,
                                                        EDNetPropertyID       pid,
                                                        const char           *pstr,
                                                        int                   pval);

Requests the server to change the property of a channel.

If 'pstr' is NULL, 'pval' parameter is used.

The result is returned via EDNET_EVENT_CHANNEL_PROPERTY event within EDNET_LINK_HOOK_EVENT hook.

client :

a EDNetClient

channel :

channel number

pid :

property id

pstr :

a string of the property, or NULL

pval :

a integer value of property

Returns :

0 on success, -1 if a error occurred.

ednet_client_add_wanted_frame_format ()

int            ednet_client_add_wanted_frame_format    (EDNetClient          *client,
                                                        int                   channel,
                                                        EDNetFrameFormat      fmt,
                                                        int                   width,
                                                        int                   height);

Adds a frame format in which the application want to received via EDNetFrame buffer within EDNET_LINK_HOOK_FRAME hook.

Even if you adds several formats, multiple frames in formats converted from a original received frame will be signaled. So, you must always check attributes of EDNetFrame buffers.

client :

a EDNetClient

channel :

channel number

fmt :

frame format

width :

the width of the video frame

height :

the height of the video frame

Returns :

0 on success, -1 if a error occurred.

ednet_client_remove_wanted_frame_format ()

int            ednet_client_remove_wanted_frame_format (EDNetClient          *client,
                                                        int                   channel,
                                                        EDNetFrameFormat      fmt,
                                                        int                   width,
                                                        int                   height);

Removes a frame format from the list of formats for specified channel.

See the description of ednet_client_add_wanted_frame_format().

client :

a EDNetClient

channel :

channel number

fmt :

frame format

width :

the width of the video frame

height :

the height of the video frame

Returns :

0 on success, -1 if a error occurred.

ednet_client_request_stream ()

int            ednet_client_request_stream             (EDNetClient          *client,
                                                        int                   channel,
                                                        int                   request);

Requests the server to control live streaming of a channel.

The result is returned via EDNET_EVENT_STREAM_REQUEST_REPLY event within EDNET_LINK_HOOK_EVENT hook.

client :

a EDNetClient

channel :

channel number

request :

TRUE for start, FALSE for cancel

Returns :

0 on success, -1 if a error occurred.

ednet_client_control_device ()

int            ednet_client_control_device             (EDNetClient          *client,
                                                        EDNetDeviceID         dev_id,
                                                        int                   dev_no,
                                                        EDNetDevicePTZCommand ptz);

Requests the server to control attached devices.

client :

a EDNetClient

dev_id :

device ID

dev_no :

device number

ptz :

device control command

Returns :

0 on success, -1 if a error occurred.

ednet_client_phone ()

int            ednet_client_phone                      (EDNetClient          *client,
                                                        EDNetPhoneCommand     cmd,
                                                        int                   src_channel,
                                                        int                   dest_channel,
                                                        int                   flags);

Transmits bidirectional audio communication (phone) commands.

client :

a EDNetClient

cmd :

phone command

src_channel :

a local audio channel number

dest_channel :

a remote audio channel number

flags :

reserved

Returns :

0 on success, -1 if a error occurred.

ednet_client_send_frame ()

int            ednet_client_send_frame                 (EDNetClient          *client,
                                                        EDNetFrame           *frame);

Transmits audio frames to the remote DVR / NT server.

Note that the channel number of a frame buffer must be EDNET_CHANNEL_AUDIO and the other fields also should be filled with valid information.

This function is used for bidirectional audio communication.

client :

a EDNetClient

frame :

a frame buffer to send

Returns :

0 on success, -1 if a error occurred.

ednet_client_send_channel_list ()

int            ednet_client_send_channel_list          (EDNetClient          *client,
                                                        int                   total,
                                                        int                  *channels);

Transmits the list of audio channels to the remote DVR / NT server.

Note that 'total' must be 1, and channels must indicate the array which has EDNET_CHANNEL_AUDIO in the first element.

This function is used for bidirectional audio communication.

client :

a EDNetClient

total :

the number of audio channels

channels :

an array of channels

Returns :

0 on success, -1 if a error occurred.

ednet_client_send_channel_property ()

int            ednet_client_send_channel_property      (EDNetClient          *client,
                                                        int                   channel,
                                                        EDNetPropertyID       pid,
                                                        const char           *pstr,
                                                        int                   pval);

Transmits the property of a channel to the remote DVR / NT server.

If 'pstr' is NULL, 'pval' parameter is used.

This function is used for bidirectional audio communication.

client :

a EDNetClient

channel :

channel number

pid :

property id

pstr :

a string of the property, or NULL

pval :

a integer value of property

Returns :

0 on success, -1 if a error occurred.

ednet_client_reply_stream ()

int            ednet_client_reply_stream               (EDNetClient          *client,
                                                        int                   channel,
                                                        int                   reply);

Transmits the reply for live streaming request to the remote DVR / NT server.

This function is used for bidirectional audio communication.

client :

a EDNetClient

channel :

channel number

reply :

TRUE for streaming started, FALSE for streaming cancelled

Returns :

0 on success, -1 if a error occurred.

ednet_client_request_config ()

int            ednet_client_request_config             (EDNetClient          *client,
                                                        const char           *section,
                                                        const char           *key);

Requests the server to retrieve the configuration value for specified section and key.

The result is returned via EDNET_EVENT_CONFIG_REPLY event within EDNET_LINK_HOOK_EVENT hook.

client :

a EDNetClient

section :

section name

key :

key name

Returns :

0 on success, -1 if a error occurred.

ednet_client_change_config ()

int            ednet_client_change_config              (EDNetClient          *client,
                                                        const char           *section,
                                                        const char           *key,
                                                        const char           *value);

Requests the server to change the configuration value for specified section and key.

The result is returned via EDNET_EVENT_CONFIG_REPLY event within EDNET_LINK_HOOK_EVENT hook.

client :

a EDNetClient

section :

section name

key :

key name

value :

value name

Returns :

0 on success, -1 if a error occurred.

ednet_client_request_dir ()

int            ednet_client_request_dir                (EDNetClient          *client,
                                                        EDNetDirType          req_type,
                                                        unsigned int          req_id,
                                                        const char           *path);

Requests the server to retrieve the entries of specified directory.

The result is returned via EDNET_EVENT_DIR_REPLY event within EDNET_LINK_HOOK_EVENT hook. The given request id will be filled in EDNetEventDirReply:req_id in order to distinguish one from multiple requests.

This function is used for remote search and replay.

client :

a EDNetClient

req_type :

directory type

req_id :

request id

path :

directory path

Returns :

0 on success, -1 if a error occurred.

ednet_client_request_mpeg_file_open ()

int            ednet_client_request_mpeg_file_open     (EDNetClient          *client,
                                                        unsigned int          req_id,
                                                        unsigned int          file_id,
                                                        const char           *name);

Requests the server to open a recorded MPEG file.

The result is returned via EDNET_EVENT_MPEG_FILE_OPEN_REPLY event within EDNET_LINK_HOOK_EVENT hook. The given request id and file id will be filled in EDNetEventMpegFileOpenReply:req_id and EDNetEventMpegFileOpenReply:file_id in order to distinguish one from multiple requests.

This function is used for remote search and replay.

client :

a EDNetClient

req_id :

request id

file_id :

file id

name :

file name

Returns :

0 on success, -1 if a error occurred.

ednet_client_request_mpeg_file_read ()

int            ednet_client_request_mpeg_file_read     (EDNetClient          *client,
                                                        unsigned int          req_id,
                                                        unsigned int          file_id,
                                                        EDNetMpegFileReadType read_type);

Requests the server to read a frame from recorded MPEG file.

The result is returned via EDNET_EVENT_MPEG_FILE_READ_REPLY event within EDNET_LINK_HOOK_EVENT hook. The given request id will be filled in EDNetEventMpegFileReadReply:req_id in order to distinguish one from multiple requests.

This function is used for remote search and replay.

client :

a EDNetClient

req_id :

request id

file_id :

file id

read_type :

reading method

Returns :

0 on success, -1 if a error occurred.

ednet_client_request_mpeg_file_seek ()

int            ednet_client_request_mpeg_file_seek     (EDNetClient          *client,
                                                        unsigned int          req_id,
                                                        unsigned int          file_id,
                                                        unsigned int          idx,
                                                        EDNetMpegFileSeekFlag flag);

Requests the server to seek in recorded MPEG file.

The result is returned via EDNET_EVENT_MPEG_FILE_SEEK_REPLY event within EDNET_LINK_HOOK_EVENT hook. The given request id will be filled in EDNetEventMpegFileSeekReply:req_id in order to distinguish one from multiple requests.

This function is used for remote search and replay.

client :

a EDNetClient

req_id :

request id

file_id :

file id

idx :

video frame index

flag :

seek method

Returns :

0 on success, -1 if a error occurred.

ednet_client_request_mpeg_file_close ()

int            ednet_client_request_mpeg_file_close    (EDNetClient          *client,
                                                        unsigned int          req_id,
                                                        unsigned int          file_id);

Requests the server to close the recorded MPEG file.

The result is returned via EDNET_EVENT_MPEG_FILE_CLOSE_REPLY event within EDNET_LINK_HOOK_EVENT hook. The given request id will be filled in EDNetEventMpegFileCloseReply:req_id in order to distinguish one from multiple requests.

This function is used for remote search and replay.

client :

a EDNetClient

req_id :

request id

file_id :

file id

Returns :

0 on success, -1 if a error occurred.

ednet_client_request_file_transfer ()

int            ednet_client_request_file_transfer      (EDNetClient          *client,
                                                        unsigned int          req_id,
                                                        const char           *filename);

Downloads specified recorded file from the remote server.

The result is returned via EDNET_EVENT_FILE_GET event within EDNET_LINK_HOOK_EVENT hook. The given request id will be filled in EDNetEventFileGet:req_id in order to distinguish one from multiple requests.

The server will divide a file into multiple packets to send them to the client. So EDNET_EVENT_FILE_GET event will be signaled several times for a file.

client :

a EDNetClient

req_id :

request id

filename :

file name

Returns :

0 on success, -1 if a error occurred.

ednet_client_cancel_file_transfer ()

int            ednet_client_cancel_file_transfer       (EDNetClient          *client,
                                                        unsigned int          req_id);

Requests the server to cancel the requested download.

client :

a EDNetClient

req_id :

request id

Returns :

0 on success, -1 if a error occurred.