Commit 0e0b7b03 authored by jehan's avatar jehan
Browse files

firt full belle sdp implementation

parent 51810110
......@@ -171,8 +171,9 @@ int belle_sdp_origin_get_session_version(const belle_sdp_origin_t* origin);
const char* belle_sdp_origin_get_username(const belle_sdp_origin_t* origin);
void belle_sdp_origin_set_address(belle_sdp_origin_t* origin, const char* address);
void belle_sdp_origin_set_address_type(belle_sdp_origin_t* origin, const char* address);
void belle_sdp_origin_set_session_id(belle_sdp_origin_t* origin, long address);
void belle_sdp_origin_set_session_version(belle_sdp_origin_t* origin, long version);
void belle_sdp_origin_set_network_type(belle_sdp_origin_t* origin, const char* network_type);
void belle_sdp_origin_set_session_id(belle_sdp_origin_t* origin, int session_id);
void belle_sdp_origin_set_session_version(belle_sdp_origin_t* origin, int version);
void belle_sdp_origin_set_username(belle_sdp_origin_t* origin, const char* username);
#define BELLE_SDP_ORIGIN(t) BELLE_SDP_CAST(t,belle_sdp_origin_t);
/***************************************************************************************
......@@ -201,7 +202,7 @@ void belle_sdp_repeate_time_set_value(belle_sdp_repeate_time_t* repeate_time, co
**************************************************************************************/
typedef struct _belle_sdp_session_name belle_sdp_session_name_t;
belle_sdp_session_name_t* belle_sdp_session_name_new();
belle_sdp_session_name_t* belle_sdp_session_name_parse (const char* session_name);
/*belle_sdp_session_name_t* belle_sdp_session_name_parse (const char* session_name);*/
const char* belle_sdp_session_name_get_value(const belle_sdp_session_name_t* session_name);
void belle_sdp_session_name_set_value(belle_sdp_session_name_t* session_name, const char* value);
#define BELLE_SDP_SESSION_NAME(t) BELLE_SDP_CAST(t,belle_sdp_session_name_t);
......@@ -212,8 +213,10 @@ void belle_sdp_session_name_set_value(belle_sdp_session_name_t* session_name, co
typedef struct _belle_sdp_time belle_sdp_time_t;
belle_sdp_time_t* belle_sdp_time_new();
belle_sdp_time_t* belle_sdp_time_parse (const char* time);
const char* belle_sdp_time_get_value(const belle_sdp_time_t* time);
void belle_sdp_time_set_value(belle_sdp_time_t* time, const char* value);
int belle_sdp_time_get_start(const belle_sdp_time_t* time);
int belle_sdp_time_get_stop(const belle_sdp_time_t* time);
void belle_sdp_time_set_start(belle_sdp_time_t* time, int value);
void belle_sdp_time_set_stop(belle_sdp_time_t* time, int value);
#define BELLE_SDP_TIME(t) BELLE_SDP_CAST(t,belle_sdp_time_t);
/***************************************************************************************
* Time description
......@@ -243,7 +246,7 @@ void belle_sdp_uri_set_value(belle_sdp_uri_t* uri, const char* value);
**************************************************************************************/
typedef struct _belle_sdp_version belle_sdp_version_t;
belle_sdp_version_t* belle_sdp_version_new();
belle_sdp_version_t* belle_sdp_version_parse (const char* version);
/*belle_sdp_version_t* belle_sdp_version_parse (const char* version);*/
int belle_sdp_version_get_version(const belle_sdp_version_t* version);
void belle_sdp_version_set_version(belle_sdp_version_t* version, int value);
#define BELLE_SDP_VERSION(t) BELLE_SDP_CAST(t,belle_sdp_version_t);
......@@ -273,14 +276,17 @@ belle_sdp_uri_t* belle_sdp_session_description_get_zone_adjustments(const belle_
void belle_sdp_session_description_remove_attribute(belle_sdp_session_description_t* session_description, const char* name);
void belle_sdp_session_description_remove_bandwidth(belle_sdp_session_description_t* session_description, const char* name);
void belle_sdp_session_description_set_attribute(belle_sdp_session_description_t* session_description, const char* name, const char* value);
void belle_sdp_session_description_add_attribute(belle_sdp_session_description_t* session_description, const belle_sdp_attribute_t* attribute);
void belle_sdp_session_description_set_attributes(belle_sdp_session_description_t* session_description, belle_sip_list_t* Attributes);
void belle_sdp_session_description_set_bandwidth(belle_sdp_session_description_t* session_description, const char* name, int value);
void belle_sdp_session_description_set_bandwidths(belle_sdp_session_description_t* session_description, belle_sip_list_t* bandwidths);
void belle_sdp_session_description_add_bandwidth(belle_sdp_session_description_t* session_description, const belle_sdp_bandwidth_t* bandwidth);
void belle_sdp_session_description_set_connection(belle_sdp_session_description_t* session_description, belle_sdp_connection_t* conn);
void belle_sdp_session_description_set_emails(belle_sdp_session_description_t* session_description, belle_sip_list_t* emails);
void belle_sdp_session_description_set_info(belle_sdp_session_description_t* session_description, belle_sdp_info_t* i);
/*void belle_sdp_session_description_set_key(belle_sdp_session_description_t* session_description, belle_sdp_key_t* key);*/
void belle_sdp_session_description_set_media_descriptions(belle_sdp_session_description_t* session_description, belle_sip_list_t* mediaDescriptions);
void belle_sdp_session_description_add_media_description(belle_sdp_session_description_t* session_description, belle_sdp_media_description_t* media_description);
void belle_sdp_session_description_set_origin(belle_sdp_session_description_t* session_description, belle_sdp_origin_t* origin);
void belle_sdp_session_description_set_phones(belle_sdp_session_description_t* session_description, belle_sip_list_t* phones);
void belle_sdp_session_description_set_session_name(belle_sdp_session_description_t* session_description, belle_sdp_session_name_t* sessionName);
......
......@@ -66,6 +66,7 @@ typedef enum belle_sip_type_id{
BELLE_SIP_TYPE_ID(belle_sip_sender_task_t),
BELLE_SIP_TYPE_ID(belle_sip_header_route_t),
BELLE_SIP_TYPE_ID(belle_sip_header_record_route_t),
BELLE_SIP_TYPE_ID(belle_sip_header_user_agent_t),
BELLE_SIP_TYPE_ID(belle_sip_header_content_length_t),
BELLE_SIP_TYPE_ID(belle_sip_header_t),
BELLE_SIP_TYPE_ID(belle_sip_header_extension_t),
......@@ -73,6 +74,8 @@ typedef enum belle_sip_type_id{
BELLE_SIP_TYPE_ID(belle_sip_header_www_authenticate_t),
BELLE_SIP_TYPE_ID(belle_sip_header_proxy_authorization_t),
BELLE_SIP_TYPE_ID(belle_sip_header_max_forwards_t),
BELLE_SIP_TYPE_ID(belle_sip_header_expires_t),
BELLE_SIP_TYPE_ID(belle_sip_header_allow_t),
BELLE_SIP_TYPE_ID(belle_sdp_attribute_t),
BELLE_SIP_TYPE_ID(belle_sdp_bandwidth_t),
BELLE_SIP_TYPE_ID(belle_sdp_connection_t),
......
......@@ -67,6 +67,21 @@ void belle_sip_header_set_name (belle_sip_header_t* obj,const char* value);
int belle_sip_header_marshal(belle_sip_header_t* header, char* buff, unsigned int offset,unsigned int buff_size);
#define BELLE_SIP_HEADER(t) BELLE_SIP_CAST(t,belle_sip_header_t)
/******************************
*
* Allow header inherit from header
*
******************************/
typedef struct _belle_sip_header_allow belle_sip_header_allow_t;
belle_sip_header_allow_t* belle_sip_header_allow_new();
belle_sip_header_allow_t* belle_sip_header_allow_parse (const char* allow) ;
const char* belle_sip_header_allow_get_method(const belle_sip_header_allow_t* allow);
void belle_sip_header_allow_set_method(belle_sip_header_allow_t* allow,const char* method);
#define BELLE_SIP_HEADER_ALLOW(t) BELLE_SIP_CAST(t,belle_sip_header_allow_t)
/***********************
* Contact header object
************************/
......@@ -218,6 +233,21 @@ void belle_sip_header_content_type_set_type(belle_sip_header_content_type_t* con
const char* belle_sip_header_content_type_get_subtype(const belle_sip_header_content_type_t* content_type);
void belle_sip_header_content_type_set_subtype(belle_sip_header_content_type_t* content_type,const char* sub_type);
#define BELLE_SIP_HEADER_CONTENT_TYPE(t) BELLE_SIP_CAST(t,belle_sip_header_content_type_t)
/******************************
*
* Expires inherit from header
*
******************************/
typedef struct _belle_sip_header_expires belle_sip_header_expires_t;
belle_sip_header_expires_t* belle_sip_header_expires_new();
belle_sip_header_expires_t* belle_sip_header_expires_parse (const char* expires) ;
int belle_sip_header_expires_get_expires(const belle_sip_header_expires_t* expires);
void belle_sip_header_expires_set_expires(belle_sip_header_expires_t* expires,int value);
int belle_sip_header_expires_decrement_expires(belle_sip_header_expires_t* expires);
#define BELLE_SIP_HEADER_EXPIRES(t) BELLE_SIP_CAST(t,belle_sip_header_expires_t)
/******************************
* Route header object inherent from header_address
*
......@@ -238,7 +268,22 @@ void belle_sip_header_content_type_set_subtype(belle_sip_header_content_type_t*
belle_sip_header_record_route_t* belle_sip_header_record_route_parse (const char* route) ;
#define BELLE_SIP_HEADER_RECORD_ROUTE(t) BELLE_SIP_CAST(t,belle_sip_header_record_route_t)
/******************************
/******************************
*
* user-Agent header inherit from header
*
******************************/
typedef struct _belle_sip_header_user_agent belle_sip_header_user_agent_t;
belle_sip_header_user_agent_t* belle_sip_header_user_agent_new();
belle_sip_header_user_agent_t* belle_sip_header_user_agent_parse (const char* user_agent) ;
belle_sip_list_t* belle_sip_header_user_agent_get_products(const belle_sip_header_user_agent_t* user_agent);
void belle_sip_header_user_agent_set_products(belle_sip_header_user_agent_t* user_agent,belle_sip_list_t* value);
void belle_sip_header_user_agent_add_product(belle_sip_header_user_agent_t* user_agent,const char* product);
#define BELLE_SIP_HEADER_USER_AGENT(t) BELLE_SIP_CAST(t,belle_sip_header_user_agent_t)
/******************************
* Content length inherent from object
*
******************************/
......
......@@ -17,7 +17,7 @@
*/
grammar belle_sdp;
options {
language = C;
output=AST;
......@@ -32,20 +32,20 @@ session_description returns [belle_sdp_session_description_t* ret]
scope { belle_sdp_session_description_t* current; }
@init {$session_description::current = belle_sdp_session_description_new(); $ret=$session_description::current; }
: version CR LF
origin CR LF
session_name_field
origin {belle_sdp_session_description_set_origin($session_description::current,$origin.ret);}CR LF
session_name CR LF
(info CR LF)?
uri_field?
(uri_field CR LF)?
(email CR LF)*
phone_field*
(connection CR LF)?
(bandwidth CR LF)*
time_field
(connection {belle_sdp_session_description_set_connection($session_description::current,$connection.ret);} CR LF)?
(bandwidth {belle_sdp_session_description_add_bandwidth($session_description::current,$bandwidth.ret);} CR LF)*
time_field CR LF
(repeat_time CR LF)?
(zone_adjustments CR LF)?
(key_field CR LF)?
(attribute CR LF)*
media_descriptions;
(attribute {belle_sdp_session_description_add_attribute($session_description::current,$attribute.ret);} CR LF)*
(media_description {belle_sdp_session_description_add_media_description($session_description::current,$media_description.ret);}) *;
version: {IS_TOKEN(v)}?alpha_num EQUAL v=DIGIT+ {belle_sdp_version_t* version =belle_sdp_version_new();
belle_sdp_version_set_version(version,atoi((const char*)$v.text->chars));
......@@ -55,12 +55,16 @@ version: {IS_TOKEN(v)}?alpha_num EQUAL v=DIGIT+ {belle_sdp_version_t* ver
origin returns [belle_sdp_origin_t* ret]
scope { belle_sdp_origin_t* current; }
@init {$origin::current = belle_sdp_origin_new(); $ret=$origin::current; }
: {IS_TOKEN(o)}?alpha_num EQUAL username SPACE
sess_id SPACE sess_version SPACE
nettype SPACE addrtype SPACE
addr ;
: {IS_TOKEN(o)}?alpha_num EQUAL username {belle_sdp_origin_set_username($origin::current,(const char*)$username.text->chars);}
SPACE sess_id {belle_sdp_origin_set_session_id($origin::current,atoi((const char*)$sess_id.text->chars));}
SPACE sess_version {belle_sdp_origin_set_session_version($origin::current,atoi((const char*)$sess_version.text->chars));}
SPACE nettype {belle_sdp_origin_set_network_type($origin::current,(const char*)$nettype.text->chars);}
SPACE addrtype {belle_sdp_origin_set_address_type($origin::current,(const char*)$addrtype.text->chars);}
SPACE addr {belle_sdp_origin_set_address($origin::current,(const char*)$addr.text->chars);} ;
session_name_field: {IS_TOKEN(s)}? alpha_num EQUAL text CR LF;
session_name: {IS_TOKEN(s)}? alpha_num EQUAL text {belle_sdp_session_name_t* session_name =belle_sdp_session_name_new();
belle_sdp_session_name_set_value(session_name,(const char*)$text.text->chars);
belle_sdp_session_description_set_session_name($session_description::current,session_name);};
info returns [belle_sdp_info_t* ret]
scope { belle_sdp_info_t* current; }
......@@ -69,7 +73,7 @@ scope { belle_sdp_info_t* current; }
info_value options { greedy = false; }: ~(CR|LF)*;
uri_field: {IS_TOKEN(u)}?alpha_num EQUAL uri CR LF;
uri_field: {IS_TOKEN(u)}?alpha_num EQUAL uri ;
email returns [belle_sdp_email_t* ret]
scope { belle_sdp_email_t* current; }
......@@ -95,7 +99,16 @@ scope { belle_sdp_bandwidth_t* current; }
: {IS_TOKEN(b)}?alpha_num EQUAL bwtype {belle_sdp_bandwidth_set_type($bandwidth::current,(const char*)$bwtype.text->chars); }
COLON bandwidth_value {belle_sdp_bandwidth_set_value($bandwidth::current,atoi((const char*)$bandwidth_value.text->chars));};
time_field: {IS_TOKEN(t)}?alpha_num EQUAL start_time SPACE stop_time;
time_field: {IS_TOKEN(t)}?alpha_num EQUAL
start_time
SPACE
stop_time {belle_sdp_time_description_t* time_description =belle_sdp_time_description_new();
belle_sdp_time_t* time_value =belle_sdp_time_new();
belle_sdp_time_set_start(time_value,atoi((const char*)$start_time.text->chars));
belle_sdp_time_set_stop(time_value,atoi((const char*)$stop_time.text->chars));
belle_sdp_time_description_set_time(time_description,time_value);
belle_sip_list_t* time_description_list = belle_sip_list_append(NULL,time_description);
belle_sdp_session_description_set_time_descriptions($session_description::current,time_description_list);};
repeat_time: {IS_TOKEN(r)}?alpha_num EQUAL repeat_interval (SPACE typed_time)+;
......@@ -115,8 +128,7 @@ key_value options { greedy = false; }: ~(CR|LF)*;
attribute returns [belle_sdp_attribute_t* ret]
scope { belle_sdp_attribute_t* current; }
@init {$attribute::current = belle_sdp_attribute_new(); $ret=$attribute::current; }: {IS_TOKEN(a)}?alpha_num EQUAL attribute_value;
media_descriptions: media_description*;
media_description returns [belle_sdp_media_description_t* ret]
scope { belle_sdp_media_description_t* current; }
@init {$media_description::current = belle_sdp_media_description_new(); $ret=$media_description::current; }
......@@ -127,7 +139,7 @@ scope { belle_sdp_media_description_t* current; }
key_field ?
(attribute {belle_sdp_media_description_add_attribute($media_description::current,$attribute.ret);} CR LF)*;
media returns [belle_sdp_media_t* ret]
scope { belle_sdp_media_t* current; }
@init {$media::current = belle_sdp_media_new(); $ret=$media::current; }
......
......@@ -427,26 +427,26 @@ void belle_sdp_media_description_set_bandwidths(belle_sdp_media_description_t* m
}
void belle_sdp_media_description_set_connection(belle_sdp_media_description_t* media_description, belle_sdp_connection_t* conn) {
belle_sdp_connection_t* current = BELLE_SIP_CAST(media_description,belle_sdp_base_description_t)->connection;
if (current) {
belle_sip_object_unref(BELLE_SIP_OBJECT(current));
belle_sdp_connection_t** current = &BELLE_SIP_CAST(media_description,belle_sdp_base_description_t)->connection;
if (*current) {
belle_sip_object_unref(BELLE_SIP_OBJECT(*current));
}
current=conn;
*current=conn;
}
void belle_sdp_media_description_set_info(belle_sdp_media_description_t* media_description,belle_sdp_info_t* i) {
belle_sdp_info_t* current = BELLE_SIP_CAST(media_description,belle_sdp_base_description_t)->info;
if (current) {
belle_sip_object_unref(BELLE_SIP_OBJECT(current));
belle_sdp_info_t** current = &BELLE_SIP_CAST(media_description,belle_sdp_base_description_t)->info;
if (*current) {
belle_sip_object_unref(BELLE_SIP_OBJECT(*current));
}
current=i;
*current=i;
}
/*void belle_sdp_media_description_set_key(belle_sdp_media_description_t* media_description,belle_sdp_key_t* key);*/
void belle_sdp_media_description_set_media(belle_sdp_media_description_t* media_description, belle_sdp_media_t* media) {
belle_sdp_media_t* current = media_description->media;
if (current) {
belle_sip_object_unref(BELLE_SIP_OBJECT(current));
belle_sdp_media_t** current = &media_description->media;
if (*current) {
belle_sip_object_unref(BELLE_SIP_OBJECT(*current));
}
current=media;
*current=media;
}
/************************
......@@ -458,6 +458,8 @@ struct _belle_sdp_origin {
const char* address_type;
const char* network_type;
const char* username;
int session_id;
int session_version;
};
......@@ -468,12 +470,49 @@ void belle_sdp_origin_clone(belle_sdp_origin_t *origin, const belle_sdp_origin_t
}
int belle_sdp_origin_marshal(belle_sdp_origin_t* origin, char* buff,unsigned int offset,unsigned int buff_size) {
unsigned int current_offset=offset;
current_offset+=snprintf( buff+current_offset
,buff_size-current_offset
,"o=%s %i %i %s %s %s"
,origin->username
,origin->session_id
,origin->session_version
,origin->network_type
,origin->address_type
,origin->address);
return current_offset-offset;
}
BELLE_SDP_NEW(origin,belle_sip_object)
BELLE_SDP_PARSE(origin)
GET_SET_STRING(belle_sdp_origin,username);
GET_SET_STRING(belle_sdp_origin,address);
GET_SET_STRING(belle_sdp_origin,address_type);
GET_SET_STRING(belle_sdp_origin,network_type);
GET_SET_INT(belle_sdp_origin,session_id,int);
GET_SET_INT(belle_sdp_origin,session_version,int);
/************************
* session_name
***********************/
struct _belle_sdp_session_name {
belle_sip_object_t base;
const char* value;
};
void belle_sdp_session_name_destroy(belle_sdp_session_name_t* session_name) {
}
void belle_sdp_session_name_clone(belle_sdp_session_name_t *session_name, const belle_sdp_session_name_t *orig){
}
int belle_sdp_session_name_marshal(belle_sdp_session_name_t* session_name, char* buff,unsigned int offset,unsigned int buff_size) {
unsigned int current_offset=offset;
current_offset+=snprintf( buff+current_offset
,buff_size-current_offset
,"s=%s"
,session_name->value);
return current_offset-offset;
}
BELLE_SDP_NEW(session_name,belle_sip_object)
//BELLE_SDP_PARSE(session_name)
GET_SET_STRING(belle_sdp_session_name,value);
/************************
......@@ -515,9 +554,30 @@ int belle_sdp_session_description_marshal(belle_sdp_session_description_t* sessi
media_descriptions;
*/
unsigned int current_offset=offset;
belle_sip_list_t* media_descriptions;
belle_sip_list_t* times;
current_offset+=belle_sip_object_marshal(BELLE_SIP_OBJECT(session_description->version),buff,current_offset,buff_size);
current_offset+=snprintf(buff+current_offset, buff_size-current_offset, "\r\n");
current_offset+=belle_sip_object_marshal(BELLE_SIP_OBJECT(session_description->origin),buff,current_offset,buff_size);
current_offset+=snprintf(buff+current_offset, buff_size-current_offset, "\r\n");
current_offset+=belle_sip_object_marshal(BELLE_SIP_OBJECT(session_description->session_name),buff,current_offset,buff_size);
current_offset+=snprintf(buff+current_offset, buff_size-current_offset, "\r\n");
current_offset+=belle_sdp_base_description_marshal((belle_sdp_base_description_t*)(&session_description->base_description),buff,current_offset,buff_size);
current_offset+=snprintf(buff+current_offset, buff_size-current_offset, "t=");
for(times=session_description->times;times!=NULL;times=times->next){
current_offset+=belle_sip_object_marshal(BELLE_SIP_OBJECT(times->data),buff,current_offset,buff_size);
current_offset+=snprintf(buff+current_offset, buff_size-current_offset, "\r\n");
}
for(media_descriptions=session_description->media_descriptions;media_descriptions!=NULL;media_descriptions=media_descriptions->next){
current_offset+=belle_sip_object_marshal(BELLE_SIP_OBJECT(media_descriptions->data),buff,current_offset,buff_size);
}
return current_offset-offset;
}
BELLE_SDP_NEW(session_description,belle_sdp_base_description)
......@@ -587,68 +647,142 @@ void belle_sdp_session_description_set_bandwidth(belle_sdp_session_description_t
void belle_sdp_session_description_set_bandwidths(belle_sdp_session_description_t* session_description, belle_sip_list_t* bandwidths) {
belle_sdp_base_description_set_bandwidths(BELLE_SIP_CAST(session_description,belle_sdp_base_description_t),bandwidths);
}
void belle_sdp_session_description_add_bandwidth(belle_sdp_session_description_t* session_description, const belle_sdp_bandwidth_t* bandwidth) {
belle_sdp_base_description_add_bandwidth(BELLE_SIP_CAST(session_description,belle_sdp_base_description_t),bandwidth);
}
void belle_sdp_session_description_set_connection(belle_sdp_session_description_t* session_description, belle_sdp_connection_t* conn) {
belle_sdp_connection_t* current = BELLE_SIP_CAST(session_description,belle_sdp_base_description_t)->connection;
if (current) {
belle_sip_object_unref(BELLE_SIP_OBJECT(current));
belle_sdp_connection_t** current = &BELLE_SIP_CAST(session_description,belle_sdp_base_description_t)->connection;
if (*current) {
belle_sip_object_unref(BELLE_SIP_OBJECT(*current));
}
current=conn;
*current=conn;
}
void belle_sdp_session_description_set_emails(belle_sdp_session_description_t* session_description, belle_sip_list_t* emails) {
SET_LIST(session_description->emails,emails)
}
void belle_sdp_session_description_set_info(belle_sdp_session_description_t* session_description, belle_sdp_info_t* i) {
belle_sdp_info_t* current = BELLE_SIP_CAST(session_description,belle_sdp_base_description_t)->info;
if (current) {
belle_sip_object_unref(BELLE_SIP_OBJECT(current));
belle_sdp_info_t** current = &BELLE_SIP_CAST(session_description,belle_sdp_base_description_t)->info;
if (*current) {
belle_sip_object_unref(BELLE_SIP_OBJECT(*current));
}
current=i;
*current=i;
}
/*void belle_sdp_session_description_set_key(belle_sdp_session_description_t* session_description, belle_sdp_key_t* key);*/
void belle_sdp_session_description_set_media_descriptions(belle_sdp_session_description_t* session_description, belle_sip_list_t* media_descriptions) {
SET_LIST(session_description->media_descriptions,media_descriptions)
}
void belle_sdp_session_description_add_media_description(belle_sdp_session_description_t* session_description, belle_sdp_media_description_t* media_description) {
session_description->media_descriptions = belle_sip_list_append(session_description->media_descriptions,media_description);
}
void belle_sdp_session_description_set_origin(belle_sdp_session_description_t* session_description, belle_sdp_origin_t* origin) {
belle_sdp_origin_t* current = session_description->origin;
if (current) {
belle_sip_object_unref(BELLE_SIP_OBJECT(current));
belle_sdp_origin_t** current = &session_description->origin;
if (*current) {
belle_sip_object_unref(BELLE_SIP_OBJECT(*current));
}
current=origin;
*current=origin;
}
void belle_sdp_session_description_set_phones(belle_sdp_session_description_t* session_description, belle_sip_list_t* phones) {
SET_LIST(session_description->phones,phones)
}
void belle_sdp_session_description_set_session_name(belle_sdp_session_description_t* session_description, belle_sdp_session_name_t* session_name) {
belle_sdp_session_name_t* current = session_description->session_name;
if (current) {
belle_sip_object_unref(BELLE_SIP_OBJECT(current));
belle_sdp_session_name_t** current = &session_description->session_name;
if (*current) {
belle_sip_object_unref(BELLE_SIP_OBJECT(*current));
}
current=session_name;
*current=session_name;
}
void belle_sdp_session_description_set_time_descriptions(belle_sdp_session_description_t* session_description, belle_sip_list_t* times) {
SET_LIST(session_description->times,times)
}
void belle_sdp_session_description_set_uri(belle_sdp_session_description_t* session_description, belle_sdp_uri_t* uri) {
belle_sdp_uri_t* current = session_description->uri;
if (current) {
belle_sip_object_unref(BELLE_SIP_OBJECT(current));
belle_sdp_uri_t** current = &session_description->uri;
if (*current) {
belle_sip_object_unref(BELLE_SIP_OBJECT(*current));
}
current=uri;
*current=uri;
}
void belle_sdp_session_description_set_version(belle_sdp_session_description_t* session_description, belle_sdp_version_t* version) {
belle_sdp_version_t* current = session_description->version;
if (current) {
belle_sip_object_unref(BELLE_SIP_OBJECT(current));
belle_sdp_version_t** current = &session_description->version;
if (*current) {
belle_sip_object_unref(BELLE_SIP_OBJECT(*current));
}
current=version;
*current=version;
}
void belle_sdp_session_description_set_zone_adjustments(belle_sdp_session_description_t* session_description, belle_sdp_uri_t* zone_adjustments) {
belle_sdp_uri_t* current = session_description->zone_adjustments;
if (current) {
belle_sip_object_unref(BELLE_SIP_OBJECT(current));
belle_sdp_uri_t** current = &session_description->zone_adjustments;
if (*current) {
belle_sip_object_unref(BELLE_SIP_OBJECT(*current));
}
*current=zone_adjustments;
}
/************************
* time
***********************/
struct _belle_sdp_time {
belle_sip_object_t base;
int start;
int stop;
};
void belle_sdp_time_destroy(belle_sdp_time_t* time) {
}
void belle_sdp_time_clone(belle_sdp_time_t *time, const belle_sdp_time_t *orig){
}
int belle_sdp_time_marshal(belle_sdp_time_t* time, char* buff,unsigned int offset,unsigned int buff_size) {
unsigned int current_offset=offset;
current_offset+=snprintf( buff+current_offset
,buff_size-current_offset
,"%i %i"
,time->start
,time->stop);
return current_offset-offset;
}
BELLE_SDP_NEW(time,belle_sip_object)
//BELLE_SDP_PARSE(version)
GET_SET_INT(belle_sdp_time,start,int);
GET_SET_INT(belle_sdp_time,stop,int);
/************************
* time description
***********************/
struct _belle_sdp_time_description {
belle_sip_object_t base;
belle_sdp_time_t* time;
};
void belle_sdp_time_description_destroy(belle_sdp_time_description_t* time_description) {
}
void belle_sdp_time_description_clone(belle_sdp_time_description_t *time_description, const belle_sdp_time_description_t *orig){
}
int belle_sdp_time_description_marshal(belle_sdp_time_description_t* time_description, char* buff,unsigned int offset,unsigned int buff_size) {
unsigned int current_offset=offset;
current_offset+=belle_sip_object_marshal(BELLE_SIP_OBJECT(time_description->time),buff,current_offset,buff_size);
return current_offset-offset;
}
BELLE_SDP_NEW(time_description,belle_sip_object)
belle_sip_list_t* belle_sdp_time_description_get_repeate_times(const belle_sdp_time_description_t* time_description) {
return NULL;
}
belle_sdp_time_t* belle_sdp_time_description_get_time(const belle_sdp_time_description_t* time_description) {
return time_description->time;
}
void belle_sdp_time_description_set_repeate_times(belle_sdp_time_description_t* time_description, belle_sip_list_t* times) {
belle_sip_error("time description repeat time not implemented");
}
void belle_sdp_time_description_set_time(belle_sdp_time_description_t* time_description, belle_sdp_time_t* value) {
belle_sdp_time_t** current = &time_description->time;
if (*current) {
belle_sip_object_unref(BELLE_SIP_OBJECT(*current));
}
current=zone_adjustments;
*current=value;
}
#define BELLE_SDP_TIME_DESCRIPTION(t) BELLE_SDP_CAST(t,belle_sdp_time_description_t);
/************************
* version
***********************/
......@@ -661,6 +795,7 @@ void belle_sdp_version_destroy(belle_sdp_version_t* version) {
}
void belle_sdp_version_clone(belle_sdp_version_t *version, const belle_sdp_version_t *orig){
}
int belle_sdp_version_marshal(belle_sdp_version_t* version, char* buff,unsigned int offset,unsigned int buff_size) {
unsigned int current_offset=offset;
......
......@@ -117,6 +117,33 @@ void belle_sip_header_address_set_uri(belle_sip_header_address_t* address, belle
}
/******************************
* Extension header hinerite from header
*
******************************/
struct _belle_sip_header_allow {
belle_sip_header_t header;
const char* method;
};
static void belle_sip_header_allow_destroy(belle_sip_header_allow_t* allow) {
if (allow->method) belle_sip_free((void*)allow->method);
}
static void belle_sip_header_allow_clone(belle_sip_header_allow_t* allow, const belle_sip_header_allow_t* orig){
}
int belle_sip_header_allow_marshal(belle_sip_header_allow_t* allow, char* buff,unsigned int offset,unsigned int buff_size) {
unsigned int current_offset=offset;
current_offset+=belle_sip_header_marshal(BELLE_SIP_HEADER(allow), buff,current_offset, buff_size);
current_offset+=snprintf(buff+current_offset,buff_size-current_offset,"%s",allow->method);
return current_offset-offset;
}
BELLE_SIP_NEW_HEADER(header_allow,header,"Allow")
BELLE_SIP_PARSE(header_allow)
GET_SET_STRING(belle_sip_header_allow,method);
/************************
* header_contact
......@@ -232,6 +259,54 @@ belle_sip_header_to_t* belle_sip_header_to_create(const char *address, const cha
return to;
}
/******************************
* User-Agent header hinerite from header
*
******************************/
struct _belle_sip_header_user_agent {
belle_sip_header_t header;
belle_sip_list_t* products;
};
static void belle_sip_header_user_agent_destroy(belle_sip_header_user_agent_t* user_agent) {
belle_sip_header_user_agent_set_products(user_agent,NULL);
}
static void belle_sip_header_user_agent_clone(belle_sip_header_user_agent_t* user_agent, const belle_sip_header_user_agent_t* orig){
}
int belle_sip_header_user_agent_marshal(belle_sip_header_user_agent_t* user_agent, char* buff,unsigned int offset,unsigned int buff_size) {
unsigned int current_offset=offset;
belle_sip_list_t* list = user_agent->products;
current_offset+=belle_sip_header_marshal(BELLE_SIP_HEADER(user_agent), buff,current_offset, buff_size);
for(;list!=NULL;list=list->next){
current_offset+=snprintf( buff+current_offset
,buff_size-current_offset