Commit f5c41494 authored by Ghislain MARY's avatar Ghislain MARY

Add new LinphoneVideoDefinition object and deprecate API functions handling MSVideoSize structures.

parent be66a259
......@@ -113,6 +113,7 @@ set(LINPHONE_SOURCE_FILES_C
siplogin.c
sipsetup.c
sqlite3_bctbx_vfs.c
video_definition.c
xml2lpc.c
xml.c
xmlrpc.c
......
......@@ -34,6 +34,7 @@ liblinphone_la_SOURCES=\
carddav.h \
call_log.c \
call_params.c \
carddav.c \
chat.c \
chat_file_transfer.c \
conference.cc conference_private.h \
......@@ -46,6 +47,7 @@ liblinphone_la_SOURCES=\
enum.c enum.h \
error_info.c \
event.c \
factory.c \
friend.c \
friendlist.c \
im_notif_policy.c \
......@@ -63,25 +65,24 @@ liblinphone_la_SOURCES=\
misc.c \
nat_policy.c \
offeranswer.c offeranswer.h\
payload_type.c \
player.c \
presence.c \
private.h \
proxy.c \
quality_reporting.c quality_reporting.h\
remote_provisioning.c \
ringtoneplayer.c \
sal.c \
siplogin.c \
sipsetup.c \
sqlite3_bctbx_vfs.c sqlite3_bctbx_vfs.h\
vcard_private.h \
vtables.c \
video_definition.c \
xml2lpc.c xml2lpc.h \
xml.c \
xmlrpc.c \
vtables.c \
carddav.c \
ringtoneplayer.c \
sqlite3_bctbx_vfs.c sqlite3_bctbx_vfs.h\
factory.c \
payload_type.c \
$(GITVERSION_FILE)
if BUILD_UPNP
......
......@@ -193,6 +193,10 @@ MSVideoSize linphone_call_params_get_received_video_size(const LinphoneCallParam
return cp->recv_vsize;
}
const LinphoneVideoDefinition * linphone_call_params_get_received_video_definition(const LinphoneCallParams *cp) {
return cp->recv_vdef;
}
const char *linphone_call_params_get_record_file(const LinphoneCallParams *cp){
return cp->record_file;
}
......@@ -209,6 +213,10 @@ MSVideoSize linphone_call_params_get_sent_video_size(const LinphoneCallParams *c
return cp->sent_vsize;
}
const LinphoneVideoDefinition * linphone_call_params_get_sent_video_definition(const LinphoneCallParams *cp) {
return cp->sent_vdef;
}
const char *linphone_call_params_get_session_name(const LinphoneCallParams *cp){
return cp->session_name;
}
......@@ -317,6 +325,8 @@ LinphoneCallParams * linphone_call_params_ref(LinphoneCallParams *cp) {
}
void linphone_call_params_unref(LinphoneCallParams *cp) {
if (cp->sent_vdef != NULL) linphone_video_definition_unref(cp->sent_vdef);
if (cp->recv_vdef != NULL) linphone_video_definition_unref(cp->recv_vdef);
belle_sip_object_unref(cp);
}
......
......@@ -38,6 +38,9 @@ typedef belle_sip_object_t_vptr_t LinphoneFactory_vptr_t;
struct _LinphoneFactory {
belle_sip_object_t base;
bctbx_list_t *supported_video_definitions;
/*these are the directories set by the application*/
char *top_resources_dir;
char *data_resources_dir;
......@@ -56,6 +59,8 @@ struct _LinphoneFactory {
};
static void linphone_factory_uninit(LinphoneFactory *obj){
bctbx_list_free_with_data(obj->supported_video_definitions, (bctbx_list_free_func)linphone_video_definition_unref);
STRING_RESET(obj->top_resources_dir);
STRING_RESET(obj->data_resources_dir);
STRING_RESET(obj->sound_resources_dir);
......@@ -87,9 +92,41 @@ static void _linphone_factory_destroying_cb(void) {
}
}
#define ADD_SUPPORTED_VIDEO_DEFINITION(factory, width, height, name) \
(factory)->supported_video_definitions = bctbx_list_append((factory)->supported_video_definitions, \
linphone_video_definition_ref(linphone_video_definition_new(width, height, name)))
static void initialize_supported_video_definitions(LinphoneFactory *factory) {
#if !defined(__ANDROID__) && !TARGET_OS_IPHONE
ADD_SUPPORTED_VIDEO_DEFINITION(factory, MS_VIDEO_SIZE_1080P_W, MS_VIDEO_SIZE_1080P_H, "1080p");
#endif
#if !defined(__ANDROID__) && !TARGET_OS_MAC /*limit to most common sizes because mac video API cannot list supported resolutions*/
ADD_SUPPORTED_VIDEO_DEFINITION(factory, MS_VIDEO_SIZE_UXGA_W, MS_VIDEO_SIZE_UXGA_H, "uxga");
ADD_SUPPORTED_VIDEO_DEFINITION(factory, MS_VIDEO_SIZE_SXGA_MINUS_W, MS_VIDEO_SIZE_SXGA_MINUS_H, "sxga-");
#endif
ADD_SUPPORTED_VIDEO_DEFINITION(factory, MS_VIDEO_SIZE_720P_W, MS_VIDEO_SIZE_720P_H, "720p");
#if !defined(__ANDROID__) && !TARGET_OS_MAC
ADD_SUPPORTED_VIDEO_DEFINITION(factory, MS_VIDEO_SIZE_XGA_W, MS_VIDEO_SIZE_XGA_H, "xga");
#endif
#if !defined(__ANDROID__) && !TARGET_OS_IPHONE
ADD_SUPPORTED_VIDEO_DEFINITION(factory, MS_VIDEO_SIZE_SVGA_W, MS_VIDEO_SIZE_SVGA_H, "svga");
ADD_SUPPORTED_VIDEO_DEFINITION(factory, MS_VIDEO_SIZE_4CIF_W, MS_VIDEO_SIZE_4CIF_H, "4cif");
#endif
ADD_SUPPORTED_VIDEO_DEFINITION(factory, MS_VIDEO_SIZE_VGA_W, MS_VIDEO_SIZE_VGA_H, "vga");
#if TARGET_OS_IPHONE
ADD_SUPPORTED_VIDEO_DEFINITION(factory, MS_VIDEO_SIZE_IOS_MEDIUM_H, MS_VIDEO_SIZE_IOS_MEDIUM_W, "ios-medium");
#endif
ADD_SUPPORTED_VIDEO_DEFINITION(factory, MS_VIDEO_SIZE_CIF_W, MS_VIDEO_SIZE_CIF_H, "cif");
#if !TARGET_OS_MAC || TARGET_OS_IPHONE /* OS_MAC is 1 for iPhone, but we need QVGA */
ADD_SUPPORTED_VIDEO_DEFINITION(factory, MS_VIDEO_SIZE_QVGA_W, MS_VIDEO_SIZE_QVGA_H, "qvga");
#endif
ADD_SUPPORTED_VIDEO_DEFINITION(factory, MS_VIDEO_SIZE_QCIF_W, MS_VIDEO_SIZE_QCIF_H, "qcif");
}
static LinphoneFactory *linphone_factory_new(void){
LinphoneFactory *factory = belle_sip_object_new(LinphoneFactory);
factory->top_resources_dir = bctbx_strdup(PACKAGE_DATA_DIR);
initialize_supported_video_definitions(factory);
return factory;
}
......@@ -141,6 +178,54 @@ LinphoneVcard *linphone_factory_create_vcard(LinphoneFactory *factory) {
return _linphone_vcard_new();
}
LinphoneVideoDefinition * linphone_factory_create_video_definition(const LinphoneFactory *factory, unsigned int width, unsigned int height) {
return linphone_video_definition_ref(linphone_video_definition_new(width, height, NULL));
}
LinphoneVideoDefinition * linphone_factory_create_video_definition_from_name(const LinphoneFactory *factory, const char *name) {
unsigned int width = 0;
unsigned int height = 0;
LinphoneVideoDefinition *vdef = linphone_factory_find_supported_video_definition_by_name(factory, name);
if (vdef != NULL) return vdef;
if (sscanf(name, "%ux%u", &width, &height) == 2) {
return linphone_video_definition_new(width, height, NULL);
}
return linphone_video_definition_new(0, 0, NULL);
}
const bctbx_list_t * linphone_factory_get_supported_video_definitions(const LinphoneFactory *factory) {
return factory->supported_video_definitions;
}
LinphoneVideoDefinition * linphone_factory_find_supported_video_definition(const LinphoneFactory *factory, unsigned int width, unsigned int height) {
const bctbx_list_t *item;
const bctbx_list_t *supported = linphone_factory_get_supported_video_definitions(factory);
LinphoneVideoDefinition *searched_vdef = linphone_video_definition_new(width, height, NULL);
for (item = supported; item != NULL; item = bctbx_list_next(item)) {
LinphoneVideoDefinition *svdef = (LinphoneVideoDefinition *)bctbx_list_get_data(item);
if (linphone_video_definition_equals(svdef, searched_vdef)) {
linphone_video_definition_unref(searched_vdef);
return svdef;
}
}
return searched_vdef;
}
LinphoneVideoDefinition * linphone_factory_find_supported_video_definition_by_name(const LinphoneFactory *factory, const char *name) {
const bctbx_list_t *item;
const bctbx_list_t *supported = linphone_factory_get_supported_video_definitions(factory);
for (item = supported; item != NULL; item = bctbx_list_next(item)) {
LinphoneVideoDefinition *svdef = (LinphoneVideoDefinition *)bctbx_list_get_data(item);
if (strcmp(linphone_video_definition_get_name(svdef), name) == 0) {
return svdef;
}
}
return NULL;
}
const char * linphone_factory_get_top_resources_dir(const LinphoneFactory *factory) {
return factory->top_resources_dir;
}
......
......@@ -1964,6 +1964,10 @@ const LinphoneCallParams * linphone_call_get_current_params(LinphoneCall *call){
#ifdef VIDEO_ENABLED
VideoStream *vstream;
#endif
if (call->current_params->sent_vdef != NULL) linphone_video_definition_unref(call->current_params->sent_vdef);
call->current_params->sent_vdef = NULL;
if (call->current_params->recv_vdef != NULL) linphone_video_definition_unref(call->current_params->recv_vdef);
call->current_params->recv_vdef = NULL;
MS_VIDEO_SIZE_ASSIGN(call->current_params->sent_vsize, UNKNOWN);
MS_VIDEO_SIZE_ASSIGN(call->current_params->recv_vsize, UNKNOWN);
#ifdef VIDEO_ENABLED
......@@ -1971,6 +1975,10 @@ const LinphoneCallParams * linphone_call_get_current_params(LinphoneCall *call){
if (vstream != NULL) {
call->current_params->sent_vsize = video_stream_get_sent_video_size(vstream);
call->current_params->recv_vsize = video_stream_get_received_video_size(vstream);
call->current_params->sent_vdef = linphone_video_definition_ref(linphone_factory_find_supported_video_definition(
linphone_factory_get(), call->current_params->sent_vsize.width, call->current_params->sent_vsize.height));
call->current_params->recv_vdef = linphone_video_definition_ref(linphone_factory_find_supported_video_definition(
linphone_factory_get(), call->current_params->recv_vsize.width, call->current_params->recv_vsize.height));
call->current_params->sent_fps = video_stream_get_sent_framerate(vstream);
call->current_params->received_fps = video_stream_get_received_framerate(vstream);
}
......
......@@ -5130,33 +5130,32 @@ int linphone_core_get_camera_sensor_rotation(LinphoneCore *lc) {
return -1;
}
static MSVideoSizeDef supported_resolutions[]={
static MSVideoSizeDef supported_resolutions[] = {
#if !defined(__ANDROID__) && !TARGET_OS_IPHONE
{ { MS_VIDEO_SIZE_1080P_W, MS_VIDEO_SIZE_1080P_H } , "1080p" },
{ { MS_VIDEO_SIZE_1080P_W, MS_VIDEO_SIZE_1080P_H }, "1080p" },
#endif
#if !defined(__ANDROID__) && !TARGET_OS_MAC /*limit to most common sizes because mac video API cannot list supported resolutions*/
{ { MS_VIDEO_SIZE_UXGA_W, MS_VIDEO_SIZE_UXGA_H } , "uxga" },
{ { MS_VIDEO_SIZE_SXGA_MINUS_W, MS_VIDEO_SIZE_SXGA_MINUS_H } , "sxga-" },
{ { MS_VIDEO_SIZE_UXGA_W, MS_VIDEO_SIZE_UXGA_H }, "uxga" },
{ { MS_VIDEO_SIZE_SXGA_MINUS_W, MS_VIDEO_SIZE_SXGA_MINUS_H }, "sxga-" },
#endif
{ { MS_VIDEO_SIZE_720P_W, MS_VIDEO_SIZE_720P_H } , "720p" },
{ { MS_VIDEO_SIZE_720P_W, MS_VIDEO_SIZE_720P_H }, "720p" },
#if !defined(__ANDROID__) && !TARGET_OS_MAC
{ { MS_VIDEO_SIZE_XGA_W, MS_VIDEO_SIZE_XGA_H } , "xga" },
{ { MS_VIDEO_SIZE_XGA_W, MS_VIDEO_SIZE_XGA_H }, "xga" },
#endif
#if !defined(__ANDROID__) && !TARGET_OS_IPHONE
{ { MS_VIDEO_SIZE_SVGA_W, MS_VIDEO_SIZE_SVGA_H } , "svga" },
{ { MS_VIDEO_SIZE_4CIF_W, MS_VIDEO_SIZE_4CIF_H } , "4cif" },
{ { MS_VIDEO_SIZE_SVGA_W, MS_VIDEO_SIZE_SVGA_H }, "svga" },
{ { MS_VIDEO_SIZE_4CIF_W, MS_VIDEO_SIZE_4CIF_H }, "4cif" },
#endif
{ { MS_VIDEO_SIZE_VGA_W, MS_VIDEO_SIZE_VGA_H } , "vga" },
{ { MS_VIDEO_SIZE_VGA_W, MS_VIDEO_SIZE_VGA_H }, "vga" },
#if TARGET_OS_IPHONE
{ { MS_VIDEO_SIZE_IOS_MEDIUM_H, MS_VIDEO_SIZE_IOS_MEDIUM_W } , "ios-medium" },
{ { MS_VIDEO_SIZE_IOS_MEDIUM_H, MS_VIDEO_SIZE_IOS_MEDIUM_W }, "ios-medium" },
#endif
{ { MS_VIDEO_SIZE_CIF_W, MS_VIDEO_SIZE_CIF_H } , "cif" },
{ { MS_VIDEO_SIZE_CIF_W, MS_VIDEO_SIZE_CIF_H }, "cif" },
#if !TARGET_OS_MAC || TARGET_OS_IPHONE /* OS_MAC is 1 for iPhone, but we need QVGA */
{ { MS_VIDEO_SIZE_QVGA_W, MS_VIDEO_SIZE_QVGA_H } , "qvga" },
{ { MS_VIDEO_SIZE_QVGA_W, MS_VIDEO_SIZE_QVGA_H } , "qvga" },
#endif
{ { MS_VIDEO_SIZE_QCIF_W, MS_VIDEO_SIZE_QCIF_H } , "qcif" },
{ { 0,0 } , NULL }
{ { MS_VIDEO_SIZE_QCIF_W, MS_VIDEO_SIZE_QCIF_H }, "qcif" },
{ { 0, 0 }, NULL }
};
const MSVideoSizeDef *linphone_core_get_supported_video_sizes(LinphoneCore *lc){
......@@ -5180,69 +5179,82 @@ static MSVideoSize video_size_get_by_name(const char *name){
return null_vsize;
}
/* warning: function not reentrant*/
static const char *video_size_get_name(MSVideoSize vsize){
MSVideoSizeDef *pdef=supported_resolutions;
static char customsize[64]={0};
for(;pdef->name!=NULL;pdef++){
if (pdef->vsize.width==vsize.width && pdef->vsize.height==vsize.height){
return pdef->name;
}
}
if (vsize.width && vsize.height){
snprintf(customsize,sizeof(customsize)-1,"%ix%i",vsize.width,vsize.height);
return customsize;
static bool_t video_definition_supported(const LinphoneVideoDefinition *vdef) {
const bctbx_list_t *item;
const bctbx_list_t *supported_definitions = linphone_factory_get_supported_video_definitions(linphone_factory_get());
for (item = supported_definitions; item != NULL; item = bctbx_list_next(item)) {
LinphoneVideoDefinition *supported_vdef = (LinphoneVideoDefinition *)bctbx_list_get_data(item);
if (linphone_video_definition_equals(vdef, supported_vdef)) return TRUE;
}
return NULL;
}
static bool_t video_size_supported(MSVideoSize vsize){
if (video_size_get_name(vsize)) return TRUE;
ms_warning("Video resolution %ix%i is not supported in linphone.",vsize.width,vsize.height);
ms_warning("Video definition %ix%i is not supported", linphone_video_definition_get_width(vdef), linphone_video_definition_get_height(vdef));
return FALSE;
}
static void update_preview_size(LinphoneCore *lc, MSVideoSize oldvsize, MSVideoSize vsize){
if (!ms_video_size_equal(oldvsize,vsize) && lc->previewstream!=NULL){
relaunch_video_preview(lc);
void linphone_core_set_preferred_video_definition(LinphoneCore *lc, LinphoneVideoDefinition *vdef) {
if (video_definition_supported(vdef)) {
LinphoneVideoDefinition *oldvdef;
if ((lc->video_conf.vdef == NULL) || linphone_video_definition_is_undefined(lc->video_conf.preview_vdef)) {
oldvdef = lc->video_conf.vdef;
} else {
oldvdef = lc->video_conf.preview_vdef;
}
if ((oldvdef == NULL) || !linphone_video_definition_equals(oldvdef, vdef)) {
lc->video_conf.vdef = linphone_video_definition_ref(vdef);
if (oldvdef != NULL) linphone_video_definition_unref(oldvdef);
if (lc->previewstream != NULL) {
relaunch_video_preview(lc);
}
}
if (linphone_core_ready(lc)) {
lp_config_set_string(lc->config, "video", "size", linphone_video_definition_get_name(vdef));
}
}
}
void linphone_core_set_preferred_video_size(LinphoneCore *lc, MSVideoSize vsize){
if (video_size_supported(vsize)){
MSVideoSize oldvsize=lc->video_conf.preview_vsize;
void linphone_core_set_preferred_video_size(LinphoneCore *lc, MSVideoSize vsize) {
linphone_core_set_preferred_video_definition(lc,
linphone_factory_find_supported_video_definition(linphone_factory_get(), vsize.width, vsize.height));
}
if (oldvsize.width==0){
oldvsize=lc->video_conf.vsize;
void linphone_core_set_preview_video_definition(LinphoneCore *lc, LinphoneVideoDefinition *vdef) {
if (!vdef || linphone_video_definition_is_undefined(vdef)) {
/* Reset the forced preview video definition mode */
if (lc->video_conf.preview_vdef != NULL) linphone_video_definition_unref(lc->video_conf.preview_vdef);
lc->video_conf.preview_vdef = NULL;
if (linphone_core_ready(lc)) {
lp_config_set_string(lc->config, "video", "preview_size", NULL);
}
lc->video_conf.vsize=vsize;
update_preview_size(lc,oldvsize,vsize);
if (linphone_core_ready(lc))
lp_config_set_string(lc->config,"video","size",video_size_get_name(vsize));
return;
}
}
void linphone_core_set_preview_video_size(LinphoneCore *lc, MSVideoSize vsize){
MSVideoSize oldvsize;
if (vsize.width==0 && vsize.height==0){
/*special case to reset the forced preview size mode*/
lc->video_conf.preview_vsize=vsize;
if (linphone_core_ready(lc))
lp_config_set_string(lc->config,"video","preview_size",NULL);
return;
if (!linphone_video_definition_equals(lc->video_conf.preview_vdef, vdef)) {
LinphoneVideoDefinition *oldvdef = lc->video_conf.preview_vdef;
lc->video_conf.preview_vdef = linphone_video_definition_ref(vdef);
if (oldvdef != NULL) linphone_video_definition_unref(oldvdef);
if (lc->previewstream != NULL) {
relaunch_video_preview(lc);
}
}
oldvsize=lc->video_conf.preview_vsize;
lc->video_conf.preview_vsize=vsize;
if (!ms_video_size_equal(oldvsize,vsize) && lc->previewstream!=NULL){
relaunch_video_preview(lc);
if (linphone_core_ready(lc)) {
lp_config_set_string(lc->config, "video", "preview_size", linphone_video_definition_get_name(vdef));
}
if (linphone_core_ready(lc))
lp_config_set_string(lc->config,"video","preview_size",video_size_get_name(vsize));
}
MSVideoSize linphone_core_get_preview_video_size(const LinphoneCore *lc){
return lc->video_conf.preview_vsize;
void linphone_core_set_preview_video_size(LinphoneCore *lc, MSVideoSize vsize) {
linphone_core_set_preview_video_definition(lc,
linphone_factory_find_supported_video_definition(linphone_factory_get(), vsize.width, vsize.height));
}
const LinphoneVideoDefinition * linphone_core_get_preview_video_definition(const LinphoneCore *lc) {
return lc->video_conf.preview_vdef;
}
MSVideoSize linphone_core_get_preview_video_size(const LinphoneCore *lc) {
MSVideoSize vsize = { 0 };
vsize.width = linphone_video_definition_get_width(lc->video_conf.preview_vdef);
vsize.height = linphone_video_definition_get_height(lc->video_conf.preview_vdef);
return vsize;
}
MSVideoSize linphone_core_get_current_preview_video_size(const LinphoneCore *lc){
......@@ -5257,11 +5269,33 @@ MSVideoSize linphone_core_get_current_preview_video_size(const LinphoneCore *lc)
return ret;
}
LinphoneVideoDefinition * linphone_core_get_current_preview_video_definition(const LinphoneCore *lc) {
#ifdef VIDEO_ENABLED
MSVideoSize vsize;
if (lc->previewstream) {
vsize = video_preview_get_current_size(lc->previewstream);
}
return linphone_factory_find_supported_video_definition(linphone_factory_get(), vsize.width, vsize.height);
#else
ms_error("Video support is disabled");
return NULL;
#endif
}
void linphone_core_set_preview_video_size_by_name(LinphoneCore *lc, const char *name){
MSVideoSize vsize=video_size_get_by_name(name);
linphone_core_set_preview_video_size(lc,vsize);
}
void linphone_core_set_preview_video_definition_by_name(LinphoneCore *lc, const char *name) {
LinphoneVideoDefinition *vdef = linphone_factory_find_supported_video_definition_by_name(linphone_factory_get(), name);
if (vdef == NULL) {
ms_error("Video definition '%s' is not supported", name);
} else {
linphone_core_set_preview_video_definition(lc, vdef);
}
}
void linphone_core_set_preferred_video_size_by_name(LinphoneCore *lc, const char *name){
MSVideoSize vsize=video_size_get_by_name(name);
MSVideoSize default_vsize={MS_VIDEO_SIZE_CIF_W,MS_VIDEO_SIZE_CIF_H};
......@@ -5269,12 +5303,28 @@ void linphone_core_set_preferred_video_size_by_name(LinphoneCore *lc, const char
else linphone_core_set_preferred_video_size(lc,default_vsize);
}
MSVideoSize linphone_core_get_preferred_video_size(const LinphoneCore *lc){
return lc->video_conf.vsize;
void linphone_core_set_preferred_video_definition_by_name(LinphoneCore *lc, const char *name) {
LinphoneVideoDefinition *vdef = linphone_factory_find_supported_video_definition_by_name(linphone_factory_get(), name);
if (vdef == NULL) {
ms_error("Video definition '%s' is not supported", name);
} else {
linphone_core_set_preferred_video_definition(lc, vdef);
}
}
const LinphoneVideoDefinition * linphone_core_get_preferred_video_definition(const LinphoneCore *lc) {
return lc->video_conf.vdef;
}
MSVideoSize linphone_core_get_preferred_video_size(const LinphoneCore *lc) {
MSVideoSize vsize = { 0 };
vsize.width = linphone_video_definition_get_width(lc->video_conf.vdef);
vsize.height = linphone_video_definition_get_height(lc->video_conf.vdef);
return vsize;
}
char * linphone_core_get_preferred_video_size_name(const LinphoneCore *lc) {
return ms_strdup(video_size_get_name(lc->video_conf.vsize));
return ms_strdup(linphone_video_definition_get_name(lc->video_conf.vdef));
}
void linphone_core_set_preferred_framerate(LinphoneCore *lc, float fps){
......@@ -5669,11 +5719,13 @@ static void sound_config_uninit(LinphoneCore *lc)
static void video_config_uninit(LinphoneCore *lc)
{
lp_config_set_string(lc->config,"video","size",video_size_get_name(linphone_core_get_preferred_video_size(lc)));
lp_config_set_string(lc->config,"video","size",linphone_video_definition_get_name(linphone_core_get_preferred_video_definition(lc)));
lp_config_set_int(lc->config,"video","display",lc->video_conf.display);
lp_config_set_int(lc->config,"video","capture",lc->video_conf.capture);
if (lc->video_conf.cams)
ms_free((void *)lc->video_conf.cams);
if (lc->video_conf.vdef) linphone_video_definition_unref(lc->video_conf.vdef);
if (lc->video_conf.preview_vdef) linphone_video_definition_unref(lc->video_conf.preview_vdef);
}
void _linphone_core_codec_config_write(LinphoneCore *lc){
......
......@@ -139,8 +139,10 @@ struct _LinphoneCallParams{
PayloadType *audio_codec; /*audio codec currently in use */
PayloadType *video_codec; /*video codec currently in use */
PayloadType *text_codec; /*text codec currently in use */
MSVideoSize sent_vsize; /* Size of the video currently being sent */
MSVideoSize recv_vsize; /* Size of the video currently being received */
MSVideoSize sent_vsize; /* DEPRECATED: Size of the video currently being sent */
MSVideoSize recv_vsize; /* DEPRECATED: Size of the video currently being received */
LinphoneVideoDefinition *sent_vdef; /* Definition of the video currently being sent */
LinphoneVideoDefinition *recv_vdef; /* Definition of the video currrently being received */
float received_fps,sent_fps;
int down_bw;
int up_bw;
......@@ -929,6 +931,8 @@ typedef struct video_config{
const char **cams;
MSVideoSize vsize;
MSVideoSize preview_vsize; /*is 0,0 if no forced preview size is set, in which case vsize field above is used.*/
LinphoneVideoDefinition *vdef;
LinphoneVideoDefinition *preview_vdef;
float fps;
bool_t capture;
bool_t show_local;
......@@ -1783,7 +1787,8 @@ BELLE_SIP_TYPE_ID(LinphoneConferenceParams),
BELLE_SIP_TYPE_ID(LinphoneConference),
BELLE_SIP_TYPE_ID(LinphoneInfoMessage),
BELLE_SIP_TYPE_ID(LinphonePayloadType),
BELLE_SIP_TYPE_ID(LinphoneRange)
BELLE_SIP_TYPE_ID(LinphoneRange),
BELLE_SIP_TYPE_ID(LinphoneVideoDefinition)
BELLE_SIP_DECLARE_TYPES_END
......@@ -1921,6 +1926,21 @@ BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneErrorInfo);
void linphone_core_report_call_log(LinphoneCore *lc, LinphoneCallLog *call_log);
void linphone_core_report_early_failed_call(LinphoneCore *lc, LinphoneCallDir dir, LinphoneAddress *from, LinphoneAddress *to, LinphoneErrorInfo *ei);
struct _LinphoneVideoDefinition {
belle_sip_object_t base;
void *user_data;
unsigned int width; /**< The width of the video */
unsigned int height; /**< The height of the video */
char *name; /** The name of the video definition */
};
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneVideoDefinition);
LinphoneVideoDefinition * linphone_video_definition_new(unsigned int width, unsigned int height, const char *name);
LinphoneVideoDefinition * linphone_factory_find_supported_video_definition(const LinphoneFactory *factory, unsigned int width, unsigned int height);
LinphoneVideoDefinition * linphone_factory_find_supported_video_definition_by_name(const LinphoneFactory *factory, const char *name);
#ifdef __cplusplus
}
#endif
......
/*
linphone
Copyright (C) 2010-2017 Belledonne Communications SARL
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "linphone/factory.h"
#include "linphone/video_definition.h"
#include "private.h"
static void linphone_video_definition_destroy(LinphoneVideoDefinition *vdef) {
if (vdef->name) bctbx_free(vdef->name);
}
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneVideoDefinition);
BELLE_SIP_INSTANCIATE_VPTR(LinphoneVideoDefinition, belle_sip_object_t,
(belle_sip_object_destroy_t)linphone_video_definition_destroy,
NULL, // clone
NULL, // marshal
TRUE
);
LinphoneVideoDefinition * linphone_video_definition_new(unsigned int width, unsigned int height, const char *name) {
LinphoneVideoDefinition *vdef = belle_sip_object_new(LinphoneVideoDefinition);
vdef->width = width;
vdef->height = height;
if (name == NULL) {
vdef->name = bctbx_strdup_printf("%ux%u", width, height);
} else {
vdef->name = bctbx_strdup(name);
}
return vdef;
}
LinphoneVideoDefinition * linphone_video_definition_ref(LinphoneVideoDefinition *vdef) {
belle_sip_object_ref(vdef);
return vdef;
}
void linphone_video_definition_unref(LinphoneVideoDefinition *vdef) {
belle_sip_object_unref(vdef);
}
void *linphone_video_definition_get_user_data(const LinphoneVideoDefinition *vdef) {
return vdef->user_data;
}
void linphone_video_definition_set_user_data(LinphoneVideoDefinition *vdef, void *ud) {
vdef->user_data = ud;
}
unsigned int linphone_video_definition_get_width(const LinphoneVideoDefinition *vdef) {