Home | History | Annotate | Download | only in src
      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:mixvideoconfigparamsdec_mp42
     11  * @short_description: VideoConfig parameters
     12  *
     13  * A data object which stores videoconfig specific parameters.
     14  */
     15 
     16 #include "mixvideolog.h"
     17 #include "mixvideoconfigparamsdec_mp42.h"
     18 
     19 static GType _mix_videoconfigparamsdec_mp42_type = 0;
     20 static MixVideoConfigParamsDecClass *parent_class = NULL;
     21 
     22 #define _do_init { _mix_videoconfigparamsdec_mp42_type = g_define_type_id; }
     23 
     24 gboolean mix_videoconfigparamsdec_mp42_copy(MixParams * target,
     25 		const MixParams * src);
     26 MixParams *mix_videoconfigparamsdec_mp42_dup(const MixParams * obj);
     27 gboolean
     28 		mix_videoconfigparamsdec_mp42_equal(MixParams * first, MixParams * second);
     29 static void mix_videoconfigparamsdec_mp42_finalize(MixParams * obj);
     30 
     31 G_DEFINE_TYPE_WITH_CODE (MixVideoConfigParamsDecMP42, /* The name of the new type, in Camel case */
     32 		mix_videoconfigparamsdec_mp42, /* The name of the new type in lowercase */
     33 		MIX_TYPE_VIDEOCONFIGPARAMSDEC, /* The GType of the parent type */
     34 		_do_init);
     35 
     36 void _mix_videoconfigparamsdec_mp42_initialize(void) {
     37 	/* the MixParams types need to be class_ref'd once before it can be
     38 	 * done from multiple threads;
     39 	 * see http://bugzilla.gnome.org/show_bug.cgi?id=304551 */
     40 	g_type_class_ref(mix_videoconfigparamsdec_mp42_get_type());
     41 }
     42 
     43 static void mix_videoconfigparamsdec_mp42_init(MixVideoConfigParamsDecMP42 * self) {
     44 	/* initialize properties here */
     45 	/* TODO: initialize properties */
     46 
     47 	self->mpegversion = 0;
     48 	self->divxversion = 0;
     49 	self->reserved1 = NULL;
     50 	self->reserved2 = NULL;
     51 	self->reserved3 = NULL;
     52 	self->reserved4 = NULL;
     53 
     54 }
     55 
     56 static void mix_videoconfigparamsdec_mp42_class_init(
     57 		MixVideoConfigParamsDecMP42Class * klass) {
     58 	MixVideoConfigParamsDecClass *this_parent_class = MIX_VIDEOCONFIGPARAMSDEC_CLASS(
     59 			klass);
     60 	MixParamsClass *this_root_class = MIX_PARAMS_CLASS(this_parent_class);
     61 
     62 	/* setup static parent class */
     63 	parent_class
     64 			= (MixVideoConfigParamsDecClass *) g_type_class_peek_parent(klass);
     65 
     66 	this_root_class->finalize = mix_videoconfigparamsdec_mp42_finalize;
     67 	this_root_class->copy
     68 			= (MixParamsCopyFunction) mix_videoconfigparamsdec_mp42_copy;
     69 	this_root_class->dup
     70 			= (MixParamsDupFunction) mix_videoconfigparamsdec_mp42_dup;
     71 	this_root_class->equal
     72 			= (MixParamsEqualFunction) mix_videoconfigparamsdec_mp42_equal;
     73 }
     74 
     75 MixVideoConfigParamsDecMP42 *
     76 mix_videoconfigparamsdec_mp42_new(void) {
     77 	MixVideoConfigParamsDecMP42 *ret =
     78 			(MixVideoConfigParamsDecMP42 *) g_type_create_instance(
     79 					MIX_TYPE_VIDEOCONFIGPARAMSDEC_MP42);
     80 
     81 	return ret;
     82 }
     83 
     84 void mix_videoconfigparamsdec_mp42_finalize(MixParams * obj) {
     85 	/*   MixVideoConfigParamsDecMP42 *this_obj = MIX_VIDEOCONFIGPARAMSDEC_MP42 (obj); */
     86 	MixParamsClass *root_class = MIX_PARAMS_CLASS(parent_class);
     87 
     88 	/* TODO: cleanup resources allocated */
     89 
     90 	/* Chain up parent */
     91 
     92 	if (root_class->finalize) {
     93 		root_class->finalize(obj);
     94 	}
     95 }
     96 
     97 MixVideoConfigParamsDecMP42 *
     98 mix_videoconfigparamsdec_mp42_ref(MixVideoConfigParamsDecMP42 * mix) {
     99 	return (MixVideoConfigParamsDecMP42 *) mix_params_ref(MIX_PARAMS(mix));
    100 }
    101 
    102 /**
    103  * mix_videoconfigparamsdec_mp42_dup:
    104  * @obj: a #MixVideoConfigParamsDec object
    105  * @returns: a newly allocated duplicate of the object.
    106  *
    107  * Copy duplicate of the object.
    108  */
    109 MixParams *
    110 mix_videoconfigparamsdec_mp42_dup(const MixParams * obj) {
    111 	MixParams *ret = NULL;
    112 
    113 	LOG_V( "Begin\n");
    114 	if (MIX_IS_VIDEOCONFIGPARAMSDEC_MP42(obj)) {
    115 		MixVideoConfigParamsDecMP42 *duplicate = mix_videoconfigparamsdec_mp42_new();
    116 		LOG_V( "duplicate = 0x%x\n", duplicate);
    117 		if (mix_videoconfigparamsdec_mp42_copy(MIX_PARAMS(duplicate), MIX_PARAMS(
    118 				obj))) {
    119 			ret = MIX_PARAMS(duplicate);
    120 		} else {
    121 			mix_videoconfigparamsdec_mp42_unref(duplicate);
    122 		}
    123 	}
    124 	LOG_V( "End\n");
    125 	return ret;
    126 }
    127 
    128 /**
    129  * mix_videoconfigparamsdec_mp42_copy:
    130  * @target: copy to target
    131  * @src: copy from src
    132  * @returns: boolean indicates if copy is successful.
    133  *
    134  * Copy instance data from @src to @target.
    135  */
    136 gboolean mix_videoconfigparamsdec_mp42_copy(MixParams * target,
    137 		const MixParams * src) {
    138 	MixVideoConfigParamsDecMP42 *this_target, *this_src;
    139 	MixParamsClass *root_class;
    140 
    141 	LOG_V( "Begin\n");
    142 	if (MIX_IS_VIDEOCONFIGPARAMSDEC_MP42(target) && MIX_IS_VIDEOCONFIGPARAMSDEC_MP42(
    143 			src)) {
    144 		// Cast the base object to this child object
    145 		this_target = MIX_VIDEOCONFIGPARAMSDEC_MP42(target);
    146 		this_src = MIX_VIDEOCONFIGPARAMSDEC_MP42(src);
    147 
    148 		// TODO: copy properties */
    149 		this_target->mpegversion = this_src->mpegversion;
    150 		this_target->divxversion = this_src->divxversion;
    151 
    152 		// Now chainup base class
    153 		root_class = MIX_PARAMS_CLASS(parent_class);
    154 
    155 		if (root_class->copy) {
    156 			LOG_V( "root_class->copy != NULL\n");
    157 			return root_class->copy(MIX_PARAMS_CAST(target), MIX_PARAMS_CAST(
    158 					src));
    159 		} else {
    160 			LOG_V( "root_class->copy == NULL\n\n");
    161 			return TRUE;
    162 		}
    163 	}
    164 	LOG_V( "End\n");
    165 	return FALSE;
    166 }
    167 
    168 /**
    169  * mix_videoconfigparamsdec_mp42:
    170  * @first: first object to compare
    171  * @second: seond object to compare
    172  * @returns: boolean indicates if instance are equal.
    173  *
    174  * Copy instance data from @src to @target.
    175  */
    176 gboolean mix_videoconfigparamsdec_mp42_equal(MixParams * first, MixParams * second) {
    177 	gboolean ret = FALSE;
    178 	MixVideoConfigParamsDecMP42 *this_first, *this_second;
    179 
    180 	if (MIX_IS_VIDEOCONFIGPARAMSDEC_MP42(first) && MIX_IS_VIDEOCONFIGPARAMSDEC_MP42(
    181 			second)) {
    182 		// Deep compare
    183 		// Cast the base object to this child object
    184 
    185 		this_first = MIX_VIDEOCONFIGPARAMSDEC_MP42(first);
    186 		this_second = MIX_VIDEOCONFIGPARAMSDEC_MP42(second);
    187 
    188 		/* TODO: add comparison for properties */
    189 		{
    190 			// members within this scope equal. chaining up.
    191 			MixParamsClass *klass = MIX_PARAMS_CLASS(parent_class);
    192 			if (klass->equal) {
    193 				ret = klass->equal(first, second);
    194 			} else {
    195 				ret = TRUE;
    196 			}
    197 		}
    198 	}
    199 
    200 	return ret;
    201 }
    202 
    203 /* TODO: Add getters and setters for properties if any */
    204 
    205 #define MIX_VIDEOCONFIGPARAMSDEC_MP42_SETTER_CHECK_INPUT(obj) \
    206 	if(!obj) return MIX_RESULT_NULL_PTR; \
    207 	if(!MIX_IS_VIDEOCONFIGPARAMSDEC_MP42(obj)) return MIX_RESULT_FAIL; \
    208 
    209 #define MIX_VIDEOCONFIGPARAMSDEC_MP42_GETTER_CHECK_INPUT(obj, prop) \
    210 	if(!obj || !prop) return MIX_RESULT_NULL_PTR; \
    211 	if(!MIX_IS_VIDEOCONFIGPARAMSDEC_MP42(obj)) return MIX_RESULT_FAIL; \
    212 
    213 
    214 MIX_RESULT mix_videoconfigparamsdec_mp42_set_mpegversion(
    215 		MixVideoConfigParamsDecMP42 *obj, guint version) {
    216 	MIX_VIDEOCONFIGPARAMSDEC_MP42_SETTER_CHECK_INPUT (obj);
    217 	obj->mpegversion = version;
    218 	return MIX_RESULT_SUCCESS;
    219 }
    220 
    221 MIX_RESULT mix_videoconfigparamsdec_mp42_get_mpegversion(
    222 		MixVideoConfigParamsDecMP42 *obj, guint *version) {
    223 	MIX_VIDEOCONFIGPARAMSDEC_MP42_GETTER_CHECK_INPUT (obj, version);
    224 	*version = obj->mpegversion;
    225 	return MIX_RESULT_SUCCESS;
    226 }
    227 
    228 MIX_RESULT mix_videoconfigparamsdec_mp42_set_divxversion(
    229 		MixVideoConfigParamsDecMP42 *obj, guint version) {
    230 
    231 	MIX_VIDEOCONFIGPARAMSDEC_MP42_SETTER_CHECK_INPUT (obj);
    232 	obj->divxversion = version;
    233 	return MIX_RESULT_SUCCESS;
    234 }
    235 
    236 MIX_RESULT mix_videoconfigparamsdec_mp42_get_divxversion(
    237 		MixVideoConfigParamsDecMP42 *obj, guint *version) {
    238 
    239 	MIX_VIDEOCONFIGPARAMSDEC_MP42_GETTER_CHECK_INPUT (obj, version);
    240 	*version = obj->divxversion;
    241 	return MIX_RESULT_SUCCESS;
    242 
    243 }
    244 
    245