Commit ff60587f authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Handle registering of video presets in the video presets manager.

parent e0fa5e65
......@@ -24,15 +24,77 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "mediastreamer2/msvideopresets.h"
typedef struct _MSVideoPresetConfiguration {
MSList *tags;
MSVideoConfiguration *config;
} MSVideoPresetConfiguration;
typedef struct _MSVideoPreset {
char *name;
MSList *configs; /**< List of MSVideoPresetConfiguration objects */
} MSVideoPreset;
struct _MSVideoPresetsManager {
MSList *presets;
MSList *presets; /**< List of MSVideoPreset objects */
};
static MSVideoPresetsManager *vpm = NULL;
static void free_preset_config(MSVideoPresetConfiguration *vpc) {
ms_list_for_each(vpc->tags, ms_free);
}
static void free_preset(MSVideoPreset *vp) {
ms_free(vp->name);
ms_list_for_each(vp->configs, (MSIterateFunc)free_preset_config);
}
static MSVideoPreset * add_video_preset(MSVideoPresetsManager *manager, const char *name) {
MSVideoPreset *vp = ms_new0(MSVideoPreset, 1);
vp->name = ms_strdup(name);
manager->presets = ms_list_append(manager->presets, vp);
return vp;
}
static MSVideoPreset * find_video_preset(MSVideoPresetsManager *manager, const char *name) {
MSList *elem = manager->presets;
while (elem != NULL) {
MSVideoPreset *vp = (MSVideoPreset *)elem->data;
if (strcmp(name, vp->name) == 0) {
return vp;
}
}
return NULL;
}
static MSList * parse_tags(const char *tags) {
MSList *tags_list = NULL;
char *t = ms_strdup(tags);
char *p = t;
while (p != NULL) {
char *next = strstr(p, ",");
if (next != NULL) {
*(next++) = '\0';
}
tags_list = ms_list_append(tags_list, ms_strdup(p));
p = next;
}
ms_free(t);
return tags_list;
}
static void add_video_preset_configuration(MSVideoPreset *preset, const char *tags, MSVideoConfiguration *config) {
MSVideoPresetConfiguration *vpc = ms_new0(MSVideoPresetConfiguration, 1);
vpc->tags = parse_tags(tags);
vpc->config = config;
preset->configs = ms_list_append(preset->configs, vpc);
}
void ms_video_presets_manager_destroy(void) {
if (vpm != NULL){
if (vpm != NULL) {
ms_list_for_each(vpm->presets, (MSIterateFunc)free_preset);
ms_list_free(vpm->presets);
ms_free(vpm);
}
vpm = NULL;
......@@ -45,5 +107,9 @@ MSVideoPresetsManager * ms_video_presets_manager_get(void) {
void ms_video_presets_manager_register_preset_configuration(MSVideoPresetsManager *manager,
const char *name, const char *tags, MSVideoConfiguration *config) {
// TODO
MSVideoPreset *preset = find_video_preset(manager, name);
if (preset == NULL) {
preset = add_video_preset(manager, name);
}
add_video_preset_configuration(preset, tags, config);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment