<commit_before>/* Egueb
 * Copyright (C) 2011 - 2013 <NAME>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.
 * If not, see <http://www.gnu.org/licenses/>.
 */
#include "egueb_dom_private.h"
#include "egueb_dom_string.h"
#include "egueb_dom_main.h"
#include "egueb_dom_node_list.h"
#include "egueb_dom_node_map_named.h"
#include "egueb_dom_node.h"

#include "egueb_dom_video_provider.h"
/*============================================================================*
 *                                  Local                                     *
 *============================================================================*/
struct _Egueb_Dom_Video_Provider
{
	const Egueb_Dom_Video_Provider_Descriptor *desc;
	const Egueb_Dom_Video_Provider_Notifier *notifier;
	Egueb_Dom_Node *n;
	Enesim_Renderer *image;
	void *data;
	int ref;
};
/*============================================================================*
 *                                 Global                                     *
 *============================================================================*/
/*============================================================================*
 *                                   API                                      *
 *============================================================================*/
EAPI Egueb_Dom_Video_Provider * egueb_dom_video_provider_new(
		const Egueb_Dom_Video_Provider_Descriptor *desc,
		const Egueb_Dom_Video_Provider_Notifier *notifier,
		Enesim_Renderer *image, Egueb_Dom_Node *n)
{
	Egueb_Dom_Video_Provider *thiz;

	if (!desc) return NULL;
	if (!image) return NULL;

	thiz = calloc(1, sizeof(Egueb_Dom_Video_Provider));
	thiz->image = image;
	thiz->notifier = notifier;
	thiz->desc = desc;
	egueb_dom_node_weak_ref_add(n, &thiz->n);
	thiz->data = thiz->desc->create();
	thiz->ref = 1;

	return thiz;
}

EAPI Egueb_Dom_Video_Provider * egueb_dom_video_provider_ref(Egueb_Dom_Video_Provider *thiz)
{
	if (!thiz) return thiz;
	thiz->ref++;
	return thiz;
}

EAPI void egueb_dom_video_provider_unref(Egueb_Dom_Video_Provider *thiz)
{
	if (!thiz) return;
	thiz->ref--;
	if (!thiz->ref)
	{
		egueb_dom_node_weak_ref_remove(thiz->n, &thiz->n);
		enesim_renderer_unref(thiz->image);
		free(thiz);
	} 
}

EAPI void * egueb_dom_video_provider_data_get(Egueb_Dom_Video_Provider *thiz)
{
	if (!thiz) return NULL;
	return thiz->data;
}

EAPI Enesim_Renderer * egueb_dom_video_provider_renderer_get(Egueb_Dom_Video_Provider *thiz)
{
	if (!thiz) return NULL;
	return enesim_renderer_ref(thiz->image);
}

EAPI void egueb_dom_video_provider_open(Egueb_Dom_Video_Provider *thiz, Egueb_Dom_String *uri)<commit_msg>Make sure to destroy the video provider<commit_after>/* Egueb
 * Copyright (C) 2011 - 2013 <NAME>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.
 * If not, see <http://www.gnu.org/licenses/>.
 */
#include "egueb_dom_private.h"
#include "egueb_dom_string.h"
#include "egueb_dom_main.h"
#include "egueb_dom_node_list.h"
#include "egueb_dom_node_map_named.h"
#include "egueb_dom_node.h"

#include "egueb_dom_video_provider.h"
/*============================================================================*
 *                                  Local                                     *
 *============================================================================*/
struct _Egueb_Dom_Video_Provider
{
	const Egueb_Dom_Video_Provider_Descriptor *desc;
	const Egueb_Dom_Video_Provider_Notifier *notifier;
	Egueb_Dom_Node *n;
	Enesim_Renderer *image;
	void *data;
	int ref;
};
/*============================================================================*
 *                                 Global                                     *
 *============================================================================*/
/*============================================================================*
 *                                   API                                      *
 *============================================================================*/
EAPI Egueb_Dom_Video_Provider * egueb_dom_video_provider_new(
		const Egueb_Dom_Video_Provider_Descriptor *desc,
		const Egueb_Dom_Video_Provider_Notifier *notifier,
		Enesim_Renderer *image, Egueb_Dom_Node *n)
{
	Egueb_Dom_Video_Provider *thiz;

	if (!desc) return NULL;
	if (!image) return NULL;

	thiz = calloc(1, sizeof(Egueb_Dom_Video_Provider));
	thiz->image = image;
	thiz->notifier = notifier;
	thiz->desc = desc;
	egueb_dom_node_weak_ref_add(n, &thiz->n);
	if (thiz->desc->create)
		thiz->data = thiz->desc->create();
	thiz->ref = 1;

	return thiz;
}

EAPI Egueb_Dom_Video_Provider * egueb_dom_video_provider_ref(Egueb_Dom_Video_Provider *thiz)
{
	if (!thiz) return thiz;
	thiz->ref++;
	return thiz;
}

EAPI void egueb_dom_video_provider_unref(Egueb_Dom_Video_Provider *thiz)
{
	if (!thiz) return;
	thiz->ref--;
	if (!thiz->ref)
	{
		if (thiz->desc->destroy)
			thiz->desc->destroy(thiz->data);
		egueb_dom_node_weak_ref_remove(thiz->n, &thiz->n);
		enesim_renderer_unref(thiz->image);
		free(thiz);
	} 
}

EAPI void * egueb_dom_video_provider_data_get(Egueb_Dom_Video_Provider *thiz)
{
	if (!thiz) return NULL;
	return thiz->data;
}

EAPI Enesim_Renderer * egueb_dom_video_provider_renderer_get(Egueb_Dom_Video_Provider *thiz)
{
	if (!thiz) return NULL;
	return enesim_renderer_ref(thiz->image);
}

EAPI void egueb_dom_video_provider_open(Egueb_Dom_Video_Provider *thiz, Egueb_Dom_String *uri)
{'fraction_non_alphanumeric': 0.2236621436194542, 'fraction_numerical': 0.0036590943741423997, 'mean_word_length': 4.231259968102074, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 46, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3854705', 'n_tokens_mistral': 2125, 'n_tokens_neox': 2039, 'n_words': 476}