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 Intel’s 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:mixvideodecodeparams
11  * @short_description: VideoDecode parameters
12  *
13  * A data object which stores videodecode specific parameters.
14  */
15 
16 #include "mixvideodecodeparams.h"
17 
18 static GType _mix_videodecodeparams_type = 0;
19 static MixParamsClass *parent_class = NULL;
20 
21 #define _do_init { _mix_videodecodeparams_type = g_define_type_id; }
22 
23 gboolean mix_videodecodeparams_copy(MixParams * target, const MixParams * src);
24 MixParams *mix_videodecodeparams_dup(const MixParams * obj);
25 gboolean mix_videodecodeparams_equal(MixParams * first, MixParams * second);
26 static void mix_videodecodeparams_finalize(MixParams * obj);
27 
28 G_DEFINE_TYPE_WITH_CODE (MixVideoDecodeParams, mix_videodecodeparams,
29 		MIX_TYPE_PARAMS, _do_init);
30 
mix_videodecodeparams_init(MixVideoDecodeParams * self)31 static void mix_videodecodeparams_init(MixVideoDecodeParams * self) {
32 	/* initialize properties here */
33 
34 	/* TODO: initialize properties */
35 
36 	self->timestamp = 0;
37 	self->discontinuity = FALSE;
38 	self->reserved1 = NULL;
39 	self->reserved2 = NULL;
40 	self->reserved3 = NULL;
41 	self->reserved4 = NULL;
42 }
43 
mix_videodecodeparams_class_init(MixVideoDecodeParamsClass * klass)44 static void mix_videodecodeparams_class_init(MixVideoDecodeParamsClass * klass) {
45 	MixParamsClass *mixparams_class = MIX_PARAMS_CLASS(klass);
46 
47 	/* setup static parent class */
48 	parent_class = (MixParamsClass *) g_type_class_peek_parent(klass);
49 
50 	mixparams_class->finalize = mix_videodecodeparams_finalize;
51 	mixparams_class->copy = (MixParamsCopyFunction) mix_videodecodeparams_copy;
52 	mixparams_class->dup = (MixParamsDupFunction) mix_videodecodeparams_dup;
53 	mixparams_class->equal
54 			= (MixParamsEqualFunction) mix_videodecodeparams_equal;
55 }
56 
57 MixVideoDecodeParams *
mix_videodecodeparams_new(void)58 mix_videodecodeparams_new(void) {
59 	MixVideoDecodeParams *ret =
60 			(MixVideoDecodeParams *) g_type_create_instance(
61 					MIX_TYPE_VIDEODECODEPARAMS);
62 
63 	return ret;
64 }
65 
mix_videodecodeparams_finalize(MixParams * obj)66 void mix_videodecodeparams_finalize(MixParams * obj) {
67 	/* clean up here. */
68 	/* TODO: cleanup resources allocated */
69 
70 	/* Chain up parent */
71 	if (parent_class->finalize) {
72 		parent_class->finalize(obj);
73 	}
74 }
75 
76 MixVideoDecodeParams *
mix_videodecodeparams_ref(MixVideoDecodeParams * mix)77 mix_videodecodeparams_ref(MixVideoDecodeParams * mix) {
78 	return (MixVideoDecodeParams *) mix_params_ref(MIX_PARAMS(mix));
79 }
80 
81 /**
82  * mix_videodecodeparams_dup:
83  * @obj: a #MixVideoDecodeParams object
84  * @returns: a newly allocated duplicate of the object.
85  *
86  * Copy duplicate of the object.
87  */
88 MixParams *
mix_videodecodeparams_dup(const MixParams * obj)89 mix_videodecodeparams_dup(const MixParams * obj) {
90 	MixParams *ret = NULL;
91 
92 	if (MIX_IS_VIDEODECODEPARAMS(obj)) {
93 		MixVideoDecodeParams *duplicate = mix_videodecodeparams_new();
94 		if (mix_videodecodeparams_copy(MIX_PARAMS(duplicate), MIX_PARAMS(obj))) {
95 			ret = MIX_PARAMS(duplicate);
96 		} else {
97 			mix_videodecodeparams_unref(duplicate);
98 		}
99 	}
100 	return ret;
101 }
102 
103 /**
104  * mix_videodecodeparams_copy:
105  * @target: copy to target
106  * @src: copy from src
107  * @returns: boolean indicates if copy is successful.
108  *
109  * Copy instance data from @src to @target.
110  */
mix_videodecodeparams_copy(MixParams * target,const MixParams * src)111 gboolean mix_videodecodeparams_copy(MixParams * target, const MixParams * src) {
112 	MixVideoDecodeParams *this_target, *this_src;
113 
114 	if (MIX_IS_VIDEODECODEPARAMS(target) && MIX_IS_VIDEODECODEPARAMS(src)) {
115 		// Cast the base object to this child object
116 		this_target = MIX_VIDEODECODEPARAMS(target);
117 		this_src = MIX_VIDEODECODEPARAMS(src);
118 
119 		// TODO: copy properties */
120 
121 		// Now chainup base class
122 		if (parent_class->copy) {
123 			return parent_class->copy(MIX_PARAMS_CAST(target), MIX_PARAMS_CAST(
124 					src));
125 		} else {
126 			return TRUE;
127 		}
128 	}
129 	return FALSE;
130 }
131 
132 /**
133  * mix_videodecodeparams_:
134  * @first: first object to compare
135  * @second: seond object to compare
136  * @returns: boolean indicates if instance are equal.
137  *
138  * Copy instance data from @src to @target.
139  */
mix_videodecodeparams_equal(MixParams * first,MixParams * second)140 gboolean mix_videodecodeparams_equal(MixParams * first, MixParams * second) {
141 	gboolean ret = FALSE;
142 	MixVideoDecodeParams *this_first, *this_second;
143 
144 	if (MIX_IS_VIDEODECODEPARAMS(first) && MIX_IS_VIDEODECODEPARAMS(second)) {
145 		// Deep compare
146 		// Cast the base object to this child object
147 
148 		this_first = MIX_VIDEODECODEPARAMS(first);
149 		this_second = MIX_VIDEODECODEPARAMS(second);
150 
151 		/* TODO: add comparison for properties */
152 		/* if ( first properties ==  sencod properties) */
153 		{
154 			// members within this scope equal. chaining up.
155 			MixParamsClass *klass = MIX_PARAMS_CLASS(parent_class);
156 			if (klass->equal)
157 				ret = parent_class->equal(first, second);
158 			else
159 				ret = TRUE;
160 		}
161 	}
162 
163 	return ret;
164 }
165 
166 #define MIX_VIDEODECODEPARAMS_SETTER_CHECK_INPUT(obj) \
167 	if(!obj) return MIX_RESULT_NULL_PTR; \
168 	if(!MIX_IS_VIDEODECODEPARAMS(obj)) return MIX_RESULT_FAIL; \
169 
170 #define MIX_VIDEODECODEPARAMS_GETTER_CHECK_INPUT(obj, prop) \
171 	if(!obj || !prop) return MIX_RESULT_NULL_PTR; \
172 	if(!MIX_IS_VIDEODECODEPARAMS(obj)) return MIX_RESULT_FAIL; \
173 
174 
175 /* TODO: Add getters and setters for properties. */
176 
mix_videodecodeparams_set_timestamp(MixVideoDecodeParams * obj,guint64 timestamp)177 MIX_RESULT mix_videodecodeparams_set_timestamp(MixVideoDecodeParams * obj,
178 		guint64 timestamp) {
179 	MIX_VIDEODECODEPARAMS_SETTER_CHECK_INPUT (obj);
180 	obj->timestamp = timestamp;
181 	return MIX_RESULT_SUCCESS;
182 }
183 
mix_videodecodeparams_get_timestamp(MixVideoDecodeParams * obj,guint64 * timestamp)184 MIX_RESULT mix_videodecodeparams_get_timestamp(MixVideoDecodeParams * obj,
185 		guint64 * timestamp) {
186 	MIX_VIDEODECODEPARAMS_GETTER_CHECK_INPUT (obj, timestamp);
187 	*timestamp = obj->timestamp;
188 	return MIX_RESULT_SUCCESS;
189 }
190 
mix_videodecodeparams_set_discontinuity(MixVideoDecodeParams * obj,gboolean discontinuity)191 MIX_RESULT mix_videodecodeparams_set_discontinuity(MixVideoDecodeParams * obj,
192 		gboolean discontinuity) {
193 	MIX_VIDEODECODEPARAMS_SETTER_CHECK_INPUT (obj);
194 	obj->discontinuity = discontinuity;
195 	return MIX_RESULT_SUCCESS;
196 }
197 
mix_videodecodeparams_get_discontinuity(MixVideoDecodeParams * obj,gboolean * discontinuity)198 MIX_RESULT mix_videodecodeparams_get_discontinuity(MixVideoDecodeParams * obj,
199 		gboolean *discontinuity) {
200 	MIX_VIDEODECODEPARAMS_GETTER_CHECK_INPUT (obj, discontinuity);
201 	*discontinuity = obj->discontinuity;
202 	return MIX_RESULT_SUCCESS;
203 }
204 
205