10 PictureItem::PictureItem()
23 PictureItem::~PictureItem()
27 void PictureItem::copy_from(PictureItem *src)
29 strcpy(this->name, src->name);
30 this->device_id = src->device_id;
33 this->default_ = src->default_;
34 this->step = src->step;
35 this->type = src->type;
36 this->value = src->value;
39 char* PictureItem::get_default_string(char *string)
41 sprintf(string, "VIDEO_%s_VALUE", name);
42 for(int i = 0; i < strlen(string); i++)
43 string[i] = toupper(string[i]);
54 PictureConfig::PictureConfig(BC_Hash *defaults)
56 this->defaults = defaults;
70 PictureConfig::~PictureConfig()
72 controls.remove_all_objects();
75 void PictureConfig::copy_settings(PictureConfig *picture)
77 this->brightness = picture->brightness;
78 this->hue = picture->hue;
79 this->color = picture->color;
80 this->contrast = picture->contrast;
81 this->whiteness = picture->whiteness;
84 for(int i = 0; i < picture->controls.total; i++)
86 PictureItem *src_item = picture->controls.values[i];
87 PictureItem *dst_item = 0;
88 for(int j = 0; j < controls.total; j++)
90 if(controls.values[j]->device_id == src_item->device_id)
92 dst_item = controls.values[j];
98 dst_item = new PictureItem;
99 controls.append(dst_item);
101 dst_item->copy_from(src_item);
105 void PictureConfig::copy_usage(PictureConfig *picture)
107 this->use_brightness = picture->use_brightness;
108 this->use_contrast = picture->use_contrast;
109 this->use_color = picture->use_color;
110 this->use_hue = picture->use_hue;
111 this->use_whiteness = picture->use_whiteness;
113 // Add the controls if they don't exists but don't replace existing values.
114 for(int i = 0; i < picture->controls.total; i++)
116 PictureItem *src = picture->controls.values[i];
118 for(int j = 0; j < controls.total; j++)
120 if(controls.values[j]->device_id == src->device_id)
128 PictureItem *dst = new PictureItem;
129 controls.append(dst);
135 void PictureConfig::load_defaults()
139 printf("PictureConfig::load_defaults: no defaults pointer.\n");
142 brightness = defaults->get("VIDEO_BRIGHTNESS", 0);
143 hue = defaults->get("VIDEO_HUE", 0);
144 color = defaults->get("VIDEO_COLOR", 0);
145 contrast = defaults->get("VIDEO_CONTRAST", 0);
146 whiteness = defaults->get("VIDEO_WHITENESS", 0);
148 // The device must be probed first to keep unsupported controls from getting
150 for(int i = 0; i < controls.total; i++)
152 PictureItem *item = controls.values[i];
153 char string[BCTEXTLEN];
154 item->get_default_string(string);
155 item->value = defaults->get(string, item->value);
156 //printf("PictureConfig::load_defaults %s %d %d\n", item->name, item->device_id, item->value);
160 void PictureConfig::save_defaults()
164 printf("PictureConfig::save_defaults: no defaults pointer.\n");
167 defaults->update("VIDEO_BRIGHTNESS", brightness);
168 defaults->update("VIDEO_HUE", hue);
169 defaults->update("VIDEO_COLOR", color);
170 defaults->update("VIDEO_CONTRAST", contrast);
171 defaults->update("VIDEO_WHITENESS", whiteness);
172 for(int i = 0; i < controls.total; i++)
174 PictureItem *item = controls.values[i];
175 char string[BCTEXTLEN];
176 item->get_default_string(string);
177 defaults->update(string, item->value);
178 //printf("PictureConfig::save_defaults %s %d %d\n", string, item->device_id, item->value);
182 void PictureConfig::dump()
184 printf(" VIDEO_BRIGHTNESS=%d\n", brightness);
185 printf(" VIDEO_HUE=%d\n", hue);
186 printf(" VIDEO_COLOR=%d\n", color);
187 printf(" VIDEO_CONTRAST=%d\n", contrast);
188 printf(" VIDEO_WHITENESS=%d\n", whiteness);
189 for(int i = 0; i < controls.total; i++)
191 PictureItem *item = controls.values[i];
192 char string[BCTEXTLEN];
193 item->get_default_string(string);
194 printf(" %s=%d\n", string, item->value);
198 PictureItem* PictureConfig::new_item(const char *name)
200 for(int i = 0; i < controls.total; i++)
202 if(!strcmp(controls.values[i]->name, name)) return controls.values[i];
204 PictureItem *item = new PictureItem;
205 strcpy(item->name, name);
206 controls.append(item);
210 PictureItem* PictureConfig::get_item(const char *name, int id)
212 for(int i = 0; i < controls.total; i++)
214 if(!strcmp(controls.values[i]->name, name) &&
215 controls.values[i]->device_id == id) return controls.values[i];
220 void PictureConfig::set_item(int device_id, int value)
222 for(int i = 0; i < controls.total; i++)
224 if(controls.values[i]->device_id == device_id)
226 controls.values[i]->value = value;