1 /* 2 INTEL CONFIDENTIAL 3 Copyright 2009 Intel Corporation All Rights Reserved. 4 The source code contained or described herein and all documents related to the source code ("Material") are owned by Intel Corporation or its suppliers or licensors. Title to the Material remains with Intel Corporation or its suppliers and licensors. The Material contains trade secrets and proprietary and confidential information of Intel or its suppliers and licensors. The Material is protected by worldwide copyright and trade secret laws and treaty provisions. No part of the Material may be used, copied, reproduced, modified, published, uploaded, posted, transmitted, distributed, or disclosed in any way without Intels prior express written permission. 5 6 No license under any patent, copyright, trade secret or other intellectual property right is granted to or conferred upon you by disclosure or delivery of the Materials, either expressly, by implication, inducement, estoppel or otherwise. Any license under such intellectual property rights must be express and approved by Intel in writing. 7 */ 8 9 /** 10 * SECTION:mixdrmparams 11 * @short_description: Drm parameters 12 * 13 * A data object which stores drm specific parameters. 14 */ 15 16 #include "mixdrmparams.h" 17 18 static GType _mix_drmparams_type = 0; 19 static MixParamsClass *parent_class = NULL; 20 21 #define _do_init { _mix_drmparams_type = g_define_type_id; } 22 23 gboolean mix_drmparams_copy (MixParams * target, const MixParams * src); 24 MixParams *mix_drmparams_dup (const MixParams * obj); 25 gboolean mix_drmparams_equal (MixParams * first, MixParams * second); 26 static void mix_drmparams_finalize (MixParams * obj); 27 28 G_DEFINE_TYPE_WITH_CODE (MixDrmParams, mix_drmparams, MIX_TYPE_PARAMS, 29 _do_init); 30 31 static void 32 mix_drmparams_init (MixDrmParams * self) 33 { 34 /* initialize properties here */ 35 36 /* TODO: initialize properties */ 37 } 38 39 static void 40 mix_drmparams_class_init (MixDrmParamsClass * klass) 41 { 42 MixParamsClass *mixparams_class = MIX_PARAMS_CLASS (klass); 43 44 /* setup static parent class */ 45 parent_class = (MixParamsClass *) g_type_class_peek_parent (klass); 46 47 mixparams_class->finalize = mix_drmparams_finalize; 48 mixparams_class->copy = (MixParamsCopyFunction) mix_drmparams_copy; 49 mixparams_class->dup = (MixParamsDupFunction) mix_drmparams_dup; 50 mixparams_class->equal = (MixParamsEqualFunction) mix_drmparams_equal; 51 } 52 53 MixDrmParams * 54 mix_drmparams_new (void) 55 { 56 MixDrmParams *ret = 57 (MixDrmParams *) g_type_create_instance (MIX_TYPE_DRMPARAMS); 58 59 return ret; 60 } 61 62 void 63 mix_drmparams_finalize (MixParams * obj) 64 { 65 /* clean up here. */ 66 /* TODO: cleanup resources allocated */ 67 68 /* Chain up parent */ 69 if (parent_class->finalize) 70 { 71 parent_class->finalize (obj); 72 } 73 } 74 75 MixDrmParams * 76 mix_drmparams_ref (MixDrmParams * mix) 77 { 78 return (MixDrmParams *) mix_params_ref (MIX_PARAMS (mix)); 79 } 80 81 /** 82 * mix_drmparams_dup: 83 * @obj: a #MixDrmParams object 84 * @returns: a newly allocated duplicate of the object. 85 * 86 * Copy duplicate of the object. 87 */ 88 MixParams * 89 mix_drmparams_dup (const MixParams * obj) 90 { 91 MixParams *ret = NULL; 92 93 if (MIX_IS_DRMPARAMS (obj)) 94 { 95 MixDrmParams *duplicate = mix_drmparams_new (); 96 if (mix_drmparams_copy (MIX_PARAMS (duplicate), MIX_PARAMS (obj))) 97 { 98 ret = MIX_PARAMS (duplicate); 99 } 100 else 101 { 102 mix_drmparams_unref (duplicate); 103 } 104 } 105 return ret; 106 } 107 108 /** 109 * mix_drmparams_copy: 110 * @target: copy to target 111 * @src: copy from src 112 * @returns: boolean indicates if copy is successful. 113 * 114 * Copy instance data from @src to @target. 115 */ 116 gboolean 117 mix_drmparams_copy (MixParams * target, const MixParams * src) 118 { 119 MixDrmParams *this_target, *this_src; 120 121 if (MIX_IS_DRMPARAMS (target) && MIX_IS_DRMPARAMS (src)) 122 { 123 // Cast the base object to this child object 124 this_target = MIX_DRMPARAMS (target); 125 this_src = MIX_DRMPARAMS (src); 126 127 // TODO: copy properties */ 128 129 // Now chainup base class 130 if (parent_class->copy) 131 { 132 return parent_class->copy (MIX_PARAMS_CAST (target), 133 MIX_PARAMS_CAST (src)); 134 } 135 else 136 { 137 return TRUE; 138 } 139 } 140 return FALSE; 141 } 142 143 /** 144 * mix_drmparams_: 145 * @first: first object to compare 146 * @second: seond object to compare 147 * @returns: boolean indicates if instance are equal. 148 * 149 * Copy instance data from @src to @target. 150 */ 151 gboolean 152 mix_drmparams_equal (MixParams * first, MixParams * second) 153 { 154 gboolean ret = FALSE; 155 MixDrmParams *this_first, *this_second; 156 157 if (MIX_IS_DRMPARAMS (first) && MIX_IS_DRMPARAMS (second)) 158 { 159 // Deep compare 160 // Cast the base object to this child object 161 162 this_first = MIX_DRMPARAMS (first); 163 this_second = MIX_DRMPARAMS (second); 164 165 /* TODO: add comparison for properties */ 166 /* if ( first properties == sencod properties) */ 167 { 168 // members within this scope equal. chaining up. 169 MixParamsClass *klass = MIX_PARAMS_CLASS (parent_class); 170 if (klass->equal) 171 ret = parent_class->equal (first, second); 172 else 173 ret = TRUE; 174 } 175 } 176 177 return ret; 178 } 179 180 #define MIX_DRMPARAMS_SETTER_CHECK_INPUT(obj) \ 181 if(!obj) return MIX_RESULT_NULL_PTR; \ 182 if(!MIX_IS_DRMPARAMS(obj)) return MIX_RESULT_FAIL; \ 183 184 #define MIX_DRMPARAMS_GETTER_CHECK_INPUT(obj, prop) \ 185 if(!obj || !prop) return MIX_RESULT_NULL_PTR; \ 186 if(!MIX_IS_DRMPARAMS(obj)) return MIX_RESULT_FAIL; \ 187 188 189 /* TODO: Add getters and setters for properties. */ 190