1 /*
2 linphone
3 Copyright (C) 2010-2017 Belledonne Communications SARL
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20 #include "linphone/factory.h"
21 #include "linphone/video_definition.h"
22
23 #include "private.h"
24
25
linphone_video_definition_destroy(LinphoneVideoDefinition * vdef)26 static void linphone_video_definition_destroy(LinphoneVideoDefinition *vdef) {
27 if (vdef->name) bctbx_free(vdef->name);
28 }
29
30 BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneVideoDefinition);
31
32 BELLE_SIP_INSTANCIATE_VPTR(LinphoneVideoDefinition, belle_sip_object_t,
33 (belle_sip_object_destroy_t)linphone_video_definition_destroy,
34 NULL, // clone
35 NULL, // marshal
36 TRUE
37 );
38
39
linphone_video_definition_new(unsigned int width,unsigned int height,const char * name)40 LinphoneVideoDefinition * linphone_video_definition_new(unsigned int width, unsigned int height, const char *name) {
41 LinphoneVideoDefinition *vdef = belle_sip_object_new(LinphoneVideoDefinition);
42 vdef->width = width;
43 vdef->height = height;
44 if (name == NULL) {
45 vdef->name = bctbx_strdup_printf("%ux%u", width, height);
46 } else {
47 vdef->name = bctbx_strdup(name);
48 }
49 return vdef;
50 }
51
linphone_video_definition_ref(LinphoneVideoDefinition * vdef)52 LinphoneVideoDefinition * linphone_video_definition_ref(LinphoneVideoDefinition *vdef) {
53 belle_sip_object_ref(vdef);
54 return vdef;
55 }
56
linphone_video_definition_unref(LinphoneVideoDefinition * vdef)57 void linphone_video_definition_unref(LinphoneVideoDefinition *vdef) {
58 belle_sip_object_unref(vdef);
59 }
60
linphone_video_definition_get_user_data(const LinphoneVideoDefinition * vdef)61 void *linphone_video_definition_get_user_data(const LinphoneVideoDefinition *vdef) {
62 return vdef->user_data;
63 }
64
linphone_video_definition_set_user_data(LinphoneVideoDefinition * vdef,void * ud)65 void linphone_video_definition_set_user_data(LinphoneVideoDefinition *vdef, void *ud) {
66 vdef->user_data = ud;
67 }
68
linphone_video_definition_clone(const LinphoneVideoDefinition * vdef)69 LinphoneVideoDefinition * linphone_video_definition_clone(const LinphoneVideoDefinition *vdef) {
70 return linphone_video_definition_new(linphone_video_definition_get_width(vdef), linphone_video_definition_get_height(vdef), linphone_video_definition_get_name(vdef));
71 }
72
linphone_video_definition_get_width(const LinphoneVideoDefinition * vdef)73 unsigned int linphone_video_definition_get_width(const LinphoneVideoDefinition *vdef) {
74 return vdef->width;
75 }
76
linphone_video_definition_set_width(LinphoneVideoDefinition * vdef,unsigned int width)77 void linphone_video_definition_set_width(LinphoneVideoDefinition *vdef, unsigned int width) {
78 vdef->width = width;
79 }
80
linphone_video_definition_get_height(const LinphoneVideoDefinition * vdef)81 unsigned int linphone_video_definition_get_height(const LinphoneVideoDefinition *vdef) {
82 return vdef->height;
83 }
84
linphone_video_definition_set_height(LinphoneVideoDefinition * vdef,unsigned int height)85 void linphone_video_definition_set_height(LinphoneVideoDefinition *vdef, unsigned int height) {
86 vdef->height = height;
87 }
88
linphone_video_definition_set_definition(LinphoneVideoDefinition * vdef,unsigned int width,unsigned int height)89 void linphone_video_definition_set_definition(LinphoneVideoDefinition *vdef, unsigned int width, unsigned int height) {
90 vdef->width = width;
91 vdef->height = height;
92 }
93
linphone_video_definition_get_name(const LinphoneVideoDefinition * vdef)94 const char * linphone_video_definition_get_name(const LinphoneVideoDefinition *vdef) {
95 return vdef->name;
96 }
97
linphone_video_definition_set_name(LinphoneVideoDefinition * vdef,const char * name)98 void linphone_video_definition_set_name(LinphoneVideoDefinition *vdef, const char *name) {
99 if (vdef->name != NULL) bctbx_free(vdef->name);
100 vdef->name = bctbx_strdup(name);
101 }
102
linphone_video_definition_equals(const LinphoneVideoDefinition * vdef1,const LinphoneVideoDefinition * vdef2)103 bool_t linphone_video_definition_equals(const LinphoneVideoDefinition *vdef1, const LinphoneVideoDefinition *vdef2) {
104 return (((vdef1->width == vdef2->width) && (vdef1->height == vdef2->height))
105 || ((vdef1->width == vdef2->height) && (vdef1->height == vdef2->width)));
106 }
107
linphone_video_definition_strict_equals(const LinphoneVideoDefinition * vdef1,const LinphoneVideoDefinition * vdef2)108 bool_t linphone_video_definition_strict_equals(const LinphoneVideoDefinition *vdef1, const LinphoneVideoDefinition *vdef2) {
109 return (vdef1->width == vdef2->width) && (vdef1->height == vdef2->height);
110 }
111
linphone_video_definition_is_undefined(const LinphoneVideoDefinition * vdef)112 bool_t linphone_video_definition_is_undefined(const LinphoneVideoDefinition *vdef) {
113 return (vdef->width == 0) || (vdef->height == 0);
114 }
115