Network Servers

차례

Synopsis
Description
Details

Network Servers - process network client connections

Synopsis

typedef EDNetServer;
struct  EDNetServerFuncs;
struct  EDNetServerConfig;

EDNetServer *ednet_server_new            (void);
EDNetServer *ednet_server_ref            (EDNetServer       *server);
void         ednet_server_unref          (EDNetServer       *server);
int          ednet_server_start          (EDNetServer       *server,
                                          EDNetServerConfig *config);
void         ednet_server_stop           (EDNetServer       *server);
void         ednet_server_fill_default   (EDNetServerConfig *config);
void         ednet_server_set_funcs      (EDNetServer       *server,
                                          EDNetServerFuncs  *funcs);
void         ednet_server_disconnect     (EDNetServer       *server,
                                          int                sid);
void         ednet_server_set_property   (EDNetServer       *server,
                                          int                channel,
                                          EDNetPropertyID    prop_id,
                                          int                prop_value,
                                          const char        *prop_str);
void         ednet_server_set_audio      (EDNetServer       *server,
                                          int                channel,
                                          int                has_input,
                                          int                has_output);
int          ednet_server_get_session    (EDNetServer       *server,
                                          int                sid,
                                          EDNetSession      *session);
int          ednet_server_get_sessions   (EDNetServer       *server,
                                          EDNetSession      *sessions,
                                          int               *total);
int          ednet_server_get_peer       (EDNetServer       *server,
                                          int                sid,
                                          int               *channel,
                                          EDNetPropertySet  *props);
void         ednet_server_phone          (EDNetServer       *server,
                                          int                sid,
                                          EDNetPhoneCommand  cmd,
                                          int                src_channel,
                                          int                dest_channel,
                                          int                flags);
void         ednet_server_notify_device  (EDNetServer       *server,
                                          EDNetDeviceID      dev_id,
                                          int                dev_no,
                                          const char        *data);
void         ednet_server_notify_session (EDNetServer       *server,
                                          int                sid,
                                          EDNetDeviceID      dev_id,
                                          int                dev_no,
                                          int                data);
EDNetBuf    *ednet_server_make_packets   (int                channel,
                                          EDNetCodecID       payload,
                                          int                is_keyframe,
                                          uint32_t           timestamp,
                                          const char        *prefix_data,
                                          int                prefix_len,
                                          const char        *frame_data,
                                          int                frame_len);
void         ednet_server_send_packets   (EDNetServer       *server,
                                          EDNetBuf          *packets);
void         ednet_server_send_frame     (EDNetServer       *server,
                                          int                channel,
                                          EDNetCodecID       payload,
                                          int                is_keyframe,
                                          uint32_t           timestamp,
                                          const char        *frame_data,
                                          int                frame_len);
void         ednet_server_set_buffering  (EDNetServer       *server,
                                          int                seconds);
void         ednet_server_control_stream (EDNetServer       *server,
                                          int                sid,
                                          int                channel,
                                          int                request);

Description

Details

EDNetServer

typedef struct _EDNetServer EDNetServer;

A server to process network connections.

EDNetServerFuncs

typedef struct
{
  void  (*receive_frame) (EDNetServer *server, int sid, EDNetFrame *frame);
  void  (*control_stream) (EDNetServer *server, int sid, int channel, int requests, int start_or_stop);
  int   (*set_property) (EDNetServer *server, int sid, int channel, EDNetPropertyID prop_id, const char *old_value, const char *new_value);
  void  (*control_device) (EDNetServer *server, int sid, EDNetDeviceID dev_id, int dev_no, EDNetDevicePTZCommand ptz_cmd);
  void  (*phone) (EDNetServer *server, int sid, EDNetPhoneCommand phone_cmd, int src_channel, int dest_channel, int flags);
  int   (*check_auth) (EDNetServer *server, int sid, const char *user, const char *enc_password);
  void  (*get_user_role) (EDNetServer *server, int sid, int user_id, char *channel_access, char *channel_streaming, char *channel_device, uint32_t *system_role);
  char * (*config_read) (EDNetServer *server, int sid, const char *key);
  void  (*config_write) (EDNetServer *server, int sid, const char *key, const char *value);
  void  (*session_changed) (EDNetServer *server, int sid, int action);
} EDNetServerFuncs;

void (*receive_frame) (EDNetServer *server, int sid, EDNetFrame *frame) :

Process frame packets received from clients.

server :

a EDNetServer

sid :

client session ID

frame :

a new frame received

void (*control_stream) (EDNetServer *server, int sid, int channel, int requests, int start_or_stop) :

Control live streaming.

server :

a EDNetServer

sid :

client session ID

channel :

channel number to control live streaming

requests :

the number of sessions for the channel

start_or_stop :

TRUE / FALSE

int (*set_property) (EDNetServer *server, int sid, int channel, EDNetPropertyID prop_id, const char *old_value, const char *new_value) :

Set the property of the channel.

server :

a EDNetServer

sid :

client session ID

channel :

channel number

prop_id :

property ID

old_value :

current property string

new_value :

new property string

Returns :

0 if it's allowed, or -1.

You don't need call ednet_server_set_property().

void (*control_device) (EDNetServer *server, int sid, EDNetDeviceID dev_id, int dev_no, EDNetDevicePTZCommand ptz_cmd) :

Control devices.

server :

a EDNetServer

sid :

client session ID

dev_id :

device ID

dev_no :

device number

ptz_cmd :

PTZ control data, see EDNetDevicePTZCommand

void (*phone) (EDNetServer *server, int sid, EDNetPhoneCommand phone_cmd, int src_channel, int dest_channel, int flags) :

Process phone signals.

server :

a EDNetServer

sid :

client session ID

phone_cmd :

phone command

src_channel :

source channel

dest_channel :

destination channel

int (*check_auth) (EDNetServer *server, int sid, const char *user, const char *enc_password) :

Check authentication and return the result.

server :

a EDNetServer

sid :

client session ID

user :

user name

enc_password :

MD5 encrypted password

Returns :

user ID, or -1 if no user, -2 if invalid password, -3 if no access right.

void (*get_user_role) (EDNetServer *server, int sid, int user_id, char *channel_access, char *channel_streaming, char *channel_device, uint32_t *system_role) :

Get user role information.

server :

a EDNetServer

sid :

client session ID

user_id :

user ID

channel_access :

channel access access to be stored

channel_streaming :

channel streaming access to be stored

channel_device :

channel device access to be stored

system :

system access to be stored

char * (*config_read) (EDNetServer *server, int sid, const char *key) :

Read the configuration value for the given key.

server :

a EDNetServer

sid :

client session ID

key :

a key string which is separated with slash(/) characters

Returns :

newly allocated value string which must be freed with free() or NULL.

void (*config_write) (EDNetServer *server, int sid, const char *key, const char *value) :

Write the configuration value for the given key.

server :

a EDNetServer

sid :

client session ID

key :

a key string which is separated with slash(/) characters

value :

a value string

void (*session_changed) (EDNetServer *server, int sid, int action) :

Notify session list change.

server :

a EDNetServer

sid :

client session ID

action :

1:added, 0:removed

EDNetServerConfig

typedef struct
{
  int  session_max;
  int  video_total;
  int  audio_total;
  int  listen_port;
  int  product_type;
  int  product_id;
  int  dio_inputs;
  int  dio_outputs;
  char disk_host_name[16];
  int  sndbuf_size;
} EDNetServerConfig;

int session_max :

int video_total :

int audio_total :

int listen_port :

int product_type :

int product_id :

int dio_inputs :

int dio_outputs :

char disk_host_name[16] :

int sndbuf_size :

ednet_server_new ()

EDNetServer *ednet_server_new            (void);

ednet_server_ref ()

EDNetServer *ednet_server_ref            (EDNetServer       *server);

ednet_server_unref ()

void         ednet_server_unref          (EDNetServer       *server);

ednet_server_start ()

int          ednet_server_start          (EDNetServer       *server,
                                          EDNetServerConfig *config);

ednet_server_stop ()

void         ednet_server_stop           (EDNetServer       *server);

ednet_server_fill_default ()

void         ednet_server_fill_default   (EDNetServerConfig *config);

ednet_server_set_funcs ()

void         ednet_server_set_funcs      (EDNetServer       *server,
                                          EDNetServerFuncs  *funcs);

ednet_server_disconnect ()

void         ednet_server_disconnect     (EDNetServer       *server,
                                          int                sid);

ednet_server_set_property ()

void         ednet_server_set_property   (EDNetServer       *server,
                                          int                channel,
                                          EDNetPropertyID    prop_id,
                                          int                prop_value,
                                          const char        *prop_str);

ednet_server_set_audio ()

void         ednet_server_set_audio      (EDNetServer       *server,
                                          int                channel,
                                          int                has_input,
                                          int                has_output);

ednet_server_get_session ()

int          ednet_server_get_session    (EDNetServer       *server,
                                          int                sid,
                                          EDNetSession      *session);

ednet_server_get_sessions ()

int          ednet_server_get_sessions   (EDNetServer       *server,
                                          EDNetSession      *sessions,
                                          int               *total);

ednet_server_get_peer ()

int          ednet_server_get_peer       (EDNetServer       *server,
                                          int                sid,
                                          int               *channel,
                                          EDNetPropertySet  *props);

ednet_server_phone ()

void         ednet_server_phone          (EDNetServer       *server,
                                          int                sid,
                                          EDNetPhoneCommand  cmd,
                                          int                src_channel,
                                          int                dest_channel,
                                          int                flags);

ednet_server_notify_device ()

void         ednet_server_notify_device  (EDNetServer       *server,
                                          EDNetDeviceID      dev_id,
                                          int                dev_no,
                                          const char        *data);

ednet_server_notify_session ()

void         ednet_server_notify_session (EDNetServer       *server,
                                          int                sid,
                                          EDNetDeviceID      dev_id,
                                          int                dev_no,
                                          int                data);

ednet_server_make_packets ()

EDNetBuf    *ednet_server_make_packets   (int                channel,
                                          EDNetCodecID       payload,
                                          int                is_keyframe,
                                          uint32_t           timestamp,
                                          const char        *prefix_data,
                                          int                prefix_len,
                                          const char        *frame_data,
                                          int                frame_len);

ednet_server_send_packets ()

void         ednet_server_send_packets   (EDNetServer       *server,
                                          EDNetBuf          *packets);

ednet_server_send_frame ()

void         ednet_server_send_frame     (EDNetServer       *server,
                                          int                channel,
                                          EDNetCodecID       payload,
                                          int                is_keyframe,
                                          uint32_t           timestamp,
                                          const char        *frame_data,
                                          int                frame_len);

ednet_server_set_buffering ()

void         ednet_server_set_buffering  (EDNetServer       *server,
                                          int                seconds);

ednet_server_control_stream ()

void         ednet_server_control_stream (EDNetServer       *server,
                                          int                sid,
                                          int                channel,
                                          int                request);