video_definition.c 3.79 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
/*
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;
}

69 70 71
LinphoneVideoDefinition * linphone_video_definition_clone(const LinphoneVideoDefinition *vdef) {
	return linphone_video_definition_new(linphone_video_definition_get_width(vdef), linphone_video_definition_get_height(vdef), linphone_video_definition_get_name(vdef));
}
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114

unsigned int linphone_video_definition_get_width(const LinphoneVideoDefinition *vdef) {
	return vdef->width;
}

void linphone_video_definition_set_width(LinphoneVideoDefinition *vdef, unsigned int width) {
	vdef->width = width;
}

unsigned int linphone_video_definition_get_height(const LinphoneVideoDefinition *vdef) {
	return vdef->height;
}

void linphone_video_definition_set_height(LinphoneVideoDefinition *vdef, unsigned int height) {
	vdef->height = height;
}

void linphone_video_definition_set_definition(LinphoneVideoDefinition *vdef, unsigned int width, unsigned int height) {
	vdef->width = width;
	vdef->height = height;
}

const char * linphone_video_definition_get_name(const LinphoneVideoDefinition *vdef) {
	return vdef->name;
}

void linphone_video_definition_set_name(LinphoneVideoDefinition *vdef, const char *name) {
	if (vdef->name != NULL) bctbx_free(vdef->name);
	vdef->name = bctbx_strdup(name);
}

bool_t linphone_video_definition_equals(const LinphoneVideoDefinition *vdef1, const LinphoneVideoDefinition *vdef2) {
	return (((vdef1->width == vdef2->width) && (vdef1->height == vdef2->height))
		|| ((vdef1->width == vdef2->height) && (vdef1->height == vdef2->width)));
}

bool_t linphone_video_definition_strict_equals(const LinphoneVideoDefinition *vdef1, const LinphoneVideoDefinition *vdef2) {
	return (vdef1->width == vdef2->width) && (vdef1->height == vdef2->height);
}

bool_t linphone_video_definition_is_undefined(const LinphoneVideoDefinition *vdef) {
	return (vdef->width == 0) || (vdef->height == 0);
}