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:mixvideoencodeparams
11 * @short_description: VideoDecode parameters
12 *
13 * A data object which stores videodecode specific parameters.
14 */
15
16 #include "mixvideoencodeparams.h"
17
18 static GType _mix_videoencodeparams_type = 0;
19 static MixParamsClass *parent_class = NULL;
20
21 #define _do_init { _mix_videoencodeparams_type = g_define_type_id; }
22
23 gboolean mix_videoencodeparams_copy(MixParams * target, const MixParams * src);
24 MixParams *mix_videoencodeparams_dup(const MixParams * obj);
25 gboolean mix_videoencodeparams_equal(MixParams * first, MixParams * second);
26 static void mix_videoencodeparams_finalize(MixParams * obj);
27
28 G_DEFINE_TYPE_WITH_CODE (MixVideoEncodeParams, mix_videoencodeparams,
29 MIX_TYPE_PARAMS, _do_init);
30
mix_videoencodeparams_init(MixVideoEncodeParams * self)31 static void mix_videoencodeparams_init(MixVideoEncodeParams * 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_videoencodeparams_class_init(MixVideoEncodeParamsClass * klass)44 static void mix_videoencodeparams_class_init(MixVideoEncodeParamsClass * 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_videoencodeparams_finalize;
51 mixparams_class->copy = (MixParamsCopyFunction) mix_videoencodeparams_copy;
52 mixparams_class->dup = (MixParamsDupFunction) mix_videoencodeparams_dup;
53 mixparams_class->equal
54 = (MixParamsEqualFunction) mix_videoencodeparams_equal;
55 }
56
57 MixVideoEncodeParams *
mix_videoencodeparams_new(void)58 mix_videoencodeparams_new(void) {
59 MixVideoEncodeParams *ret =
60 (MixVideoEncodeParams *) g_type_create_instance(
61 MIX_TYPE_VIDEOENCODEPARAMS);
62
63 return ret;
64 }
65
mix_videoencodeparams_finalize(MixParams * obj)66 void mix_videoencodeparams_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 MixVideoEncodeParams *
mix_videoencodeparams_ref(MixVideoEncodeParams * mix)77 mix_videoencodeparams_ref(MixVideoEncodeParams * mix) {
78 return (MixVideoEncodeParams *) mix_params_ref(MIX_PARAMS(mix));
79 }
80
81 /**
82 * mix_videoencodeparams_dup:
83 * @obj: a #MixVideoEncodeParams object
84 * @returns: a newly allocated duplicate of the object.
85 *
86 * Copy duplicate of the object.
87 */
88 MixParams *
mix_videoencodeparams_dup(const MixParams * obj)89 mix_videoencodeparams_dup(const MixParams * obj) {
90 MixParams *ret = NULL;
91
92 if (MIX_IS_VIDEOENCODEPARAMS(obj)) {
93 MixVideoEncodeParams *duplicate = mix_videoencodeparams_new();
94 if (mix_videoencodeparams_copy(MIX_PARAMS(duplicate), MIX_PARAMS(obj))) {
95 ret = MIX_PARAMS(duplicate);
96 } else {
97 mix_videoencodeparams_unref(duplicate);
98 }
99 }
100 return ret;
101 }
102
103 /**
104 * mix_videoencodeparams_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_videoencodeparams_copy(MixParams * target,const MixParams * src)111 gboolean mix_videoencodeparams_copy(MixParams * target, const MixParams * src) {
112 MixVideoEncodeParams *this_target, *this_src;
113
114 if (MIX_IS_VIDEOENCODEPARAMS(target) && MIX_IS_VIDEOENCODEPARAMS(src)) {
115 // Cast the base object to this child object
116 this_target = MIX_VIDEOENCODEPARAMS(target);
117 this_src = MIX_VIDEOENCODEPARAMS(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_videoencodeparams_:
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_videoencodeparams_equal(MixParams * first,MixParams * second)140 gboolean mix_videoencodeparams_equal(MixParams * first, MixParams * second) {
141 gboolean ret = FALSE;
142 MixVideoEncodeParams *this_first, *this_second;
143
144 if (MIX_IS_VIDEOENCODEPARAMS(first) && MIX_IS_VIDEOENCODEPARAMS(second)) {
145 // Deep compare
146 // Cast the base object to this child object
147
148 this_first = MIX_VIDEOENCODEPARAMS(first);
149 this_second = MIX_VIDEOENCODEPARAMS(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_VIDEOENCODEPARAMS_SETTER_CHECK_INPUT(obj) \
167 if(!obj) return MIX_RESULT_NULL_PTR; \
168 if(!MIX_IS_VIDEOENCODEPARAMS(obj)) return MIX_RESULT_FAIL; \
169
170 #define MIX_VIDEOENCODEPARAMS_GETTER_CHECK_INPUT(obj, prop) \
171 if(!obj || !prop) return MIX_RESULT_NULL_PTR; \
172 if(!MIX_IS_VIDEOENCODEPARAMS(obj)) return MIX_RESULT_FAIL; \
173
174
175 /* TODO: Add getters and setters for properties. */
176
mix_videoencodeparams_set_timestamp(MixVideoEncodeParams * obj,guint64 timestamp)177 MIX_RESULT mix_videoencodeparams_set_timestamp(MixVideoEncodeParams * obj,
178 guint64 timestamp) {
179 MIX_VIDEOENCODEPARAMS_SETTER_CHECK_INPUT (obj);
180 obj->timestamp = timestamp;
181 return MIX_RESULT_SUCCESS;
182 }
183
mix_videoencodeparams_get_timestamp(MixVideoEncodeParams * obj,guint64 * timestamp)184 MIX_RESULT mix_videoencodeparams_get_timestamp(MixVideoEncodeParams * obj,
185 guint64 * timestamp) {
186 MIX_VIDEOENCODEPARAMS_GETTER_CHECK_INPUT (obj, timestamp);
187 *timestamp = obj->timestamp;
188 return MIX_RESULT_SUCCESS;
189 }
190
mix_videoencodeparams_set_discontinuity(MixVideoEncodeParams * obj,gboolean discontinuity)191 MIX_RESULT mix_videoencodeparams_set_discontinuity(MixVideoEncodeParams * obj,
192 gboolean discontinuity) {
193 MIX_VIDEOENCODEPARAMS_SETTER_CHECK_INPUT (obj);
194 obj->discontinuity = discontinuity;
195 return MIX_RESULT_SUCCESS;
196 }
197
mix_videoencodeparams_get_discontinuity(MixVideoEncodeParams * obj,gboolean * discontinuity)198 MIX_RESULT mix_videoencodeparams_get_discontinuity(MixVideoEncodeParams * obj,
199 gboolean *discontinuity) {
200 MIX_VIDEOENCODEPARAMS_GETTER_CHECK_INPUT (obj, discontinuity);
201 *discontinuity = obj->discontinuity;
202 return MIX_RESULT_SUCCESS;
203 }
204
205