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:mixvideoconfigparams
11 * @short_description: VideoConfig parameters
12 *
13 * A data object which stores videoconfig specific parameters.
14 */
15
16 #include <string.h>
17 #include "mixvideolog.h"
18 #include "mixvideoconfigparams.h"
19
20 static GType _mix_videoconfigparams_type = 0;
21 static MixParamsClass *parent_class = NULL;
22
23 #define _do_init { _mix_videoconfigparams_type = g_define_type_id; }
24
25 gboolean mix_videoconfigparams_copy(MixParams * target, const MixParams * src);
26 MixParams *mix_videoconfigparams_dup(const MixParams * obj);
27 gboolean mix_videoconfigparams_equal(MixParams * first, MixParams * second);
28 static void mix_videoconfigparams_finalize(MixParams * obj);
29
30 G_DEFINE_TYPE_WITH_CODE (MixVideoConfigParams, mix_videoconfigparams,
31 MIX_TYPE_PARAMS, _do_init);
32
mix_videoconfigparams_init(MixVideoConfigParams * self)33 static void mix_videoconfigparams_init(MixVideoConfigParams * self) {
34
35 /* initialize properties here */
36 self->reserved1 = NULL;
37 self->reserved2 = NULL;
38 self->reserved3 = NULL;
39 self->reserved4 = NULL;
40 }
41
mix_videoconfigparams_class_init(MixVideoConfigParamsClass * klass)42 static void mix_videoconfigparams_class_init(MixVideoConfigParamsClass * klass) {
43 MixParamsClass *mixparams_class = MIX_PARAMS_CLASS(klass);
44
45 /* setup static parent class */
46 parent_class = (MixParamsClass *) g_type_class_peek_parent(klass);
47
48 mixparams_class->finalize = mix_videoconfigparams_finalize;
49 mixparams_class->copy = (MixParamsCopyFunction) mix_videoconfigparams_copy;
50 mixparams_class->dup = (MixParamsDupFunction) mix_videoconfigparams_dup;
51 mixparams_class->equal
52 = (MixParamsEqualFunction) mix_videoconfigparams_equal;
53 }
54
55 MixVideoConfigParams *
mix_videoconfigparams_new(void)56 mix_videoconfigparams_new(void) {
57 MixVideoConfigParams *ret =
58 (MixVideoConfigParams *) g_type_create_instance(
59 MIX_TYPE_VIDEOCONFIGPARAMS);
60
61 return ret;
62 }
63
mix_videoconfigparams_finalize(MixParams * obj)64 void mix_videoconfigparams_finalize(MixParams * obj) {
65
66 /* clean up here. */
67 /* MixVideoConfigParams *self = MIX_VIDEOCONFIGPARAMS(obj); */
68
69 /* Chain up parent */
70 if (parent_class->finalize) {
71 parent_class->finalize(obj);
72 }
73 }
74
75 MixVideoConfigParams *
mix_videoconfigparams_ref(MixVideoConfigParams * mix)76 mix_videoconfigparams_ref(MixVideoConfigParams * mix) {
77 return (MixVideoConfigParams *) mix_params_ref(MIX_PARAMS(mix));
78 }
79
80 /**
81 * mix_videoconfigparams_dup:
82 * @obj: a #MixVideoConfigParams object
83 * @returns: a newly allocated duplicate of the object.
84 *
85 * Copy duplicate of the object.
86 */
87 MixParams *
mix_videoconfigparams_dup(const MixParams * obj)88 mix_videoconfigparams_dup(const MixParams * obj) {
89 MixParams *ret = NULL;
90
91 if (MIX_IS_VIDEOCONFIGPARAMS(obj)) {
92 MixVideoConfigParams *duplicate = mix_videoconfigparams_new();
93 if (mix_videoconfigparams_copy(MIX_PARAMS(duplicate), MIX_PARAMS(obj))) {
94 ret = MIX_PARAMS(duplicate);
95 } else {
96 mix_videoconfigparams_unref(duplicate);
97 }
98 }
99
100 return ret;
101 }
102
103 /**
104 * mix_videoconfigparams_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_videoconfigparams_copy(MixParams * target,const MixParams * src)111 gboolean mix_videoconfigparams_copy(MixParams * target, const MixParams * src) {
112
113 LOG_V( "Begin\n");
114
115 if (MIX_IS_VIDEOCONFIGPARAMS(target) && MIX_IS_VIDEOCONFIGPARAMS(src)) {
116
117 /* TODO: copy other properties if there's any */
118
119 /* Now chainup base class */
120 if (parent_class->copy) {
121 LOG_V( "parent_class->copy != NULL\n");
122 return parent_class->copy(MIX_PARAMS_CAST(target), MIX_PARAMS_CAST(
123 src));
124 } else {
125 LOG_V( "parent_class->copy == NULL\n");
126 return TRUE;
127 }
128 }
129
130 LOG_V( "End\n");
131 return FALSE;
132 }
133
134 /**
135 * mix_videoconfigparams_:
136 * @first: first object to compare
137 * @second: seond object to compare
138 * @returns: boolean indicates if instance are equal.
139 *
140 * Copy instance data from @src to @target.
141 */
mix_videoconfigparams_equal(MixParams * first,MixParams * second)142 gboolean mix_videoconfigparams_equal(MixParams * first, MixParams * second) {
143
144 gboolean ret = FALSE;
145
146 if (MIX_IS_VIDEOCONFIGPARAMS(first) && MIX_IS_VIDEOCONFIGPARAMS(second)) {
147
148 /* chaining up. */
149 MixParamsClass *klass = MIX_PARAMS_CLASS(parent_class);
150 if (klass->equal)
151 ret = parent_class->equal(first, second);
152 else
153 ret = TRUE;
154 }
155
156 return ret;
157 }
158