<commit_before>/*****************************************************************************
 * events.h: events definitions
 * Interface used to send events.
 *****************************************************************************
 * Copyright (C) 2007 the VideoLAN team
 * $Id$
 *
 * Authors: <NAME>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

#ifndef VLC_EVENTS_H
# define VLC_EVENTS_H

#include <vlc_arrays.h>
#include <vlc_meta.h>

/**
 * \file
 * This file is the interface definition for events
 * (implementation in src/misc/events.c)
 */

/*****************************************************************************
 * Documentation
 *****************************************************************************/
/*
 **** Background
 *
 * This implements a way to send and receive event for an object (which can be
 * a simple C struct or less).
 *
 * This is in direct concurrency with the Variable based Callback
 * (see src/misc/variables.c).
 *
 * It has the following advantages over Variable based Callback:
 * - No need to implement the whole VLC_COMMON_MEMBERS in the object,
 * thus it reduce it size. This is especially true for input_item_t which
 * doesn't have VLC_COMMON_MEMBERS. This is the first reason of existence of
 * this implementation.
 * - Libvlc can easily be based upon that.
 * - Existing event are clearly declared (in include/vlc_events.h)
 *
 *
 **** Example usage
 *
 * (vlc_cool_object_t doesn't need to have the VLC_COMMON_MEMBERS.)
 *
 * struct vlc_cool_object_t
 * {
 *        ...
 *        vlc_event_manager_t p_event_manager;
 *        ...
 * }
 *
 * vlc_my_cool_object_new()
 * {
 *        ...
 *        vlc_event_manager_init( &p_self->p_event_manager, p_self, p_a_libvlc_object );
 *        vlc_event_manager_register_event_type(p_self->p_event_manager,
 *                vlc_MyCoolObjectDidSomething, p_e)
 *        ...
 * }
 *
 * vlc_my_cool_object_release()
 * {
 *         ...
 *         vlc_event_manager_fini( &p_self->p_event_manager );
 *         ...
 * }
 *
 * vlc_my_cool_object_do_something()
 * {
 *        ...
 *        vlc_event_t event;
 *        event.type = vlc_MyCoolObjectDidSomething;
 *        event.u.my_cool_object_did_something.what_it_did = kSomething;
 *        vlc_event_send( &p_self->p_event_manager, &event );
 * }
 * */

  /*****************************************************************************
 * Event Type
 *****************************************************************************/

/* Private structure defined in misc/events.c */
struct vlc_event_listeners_group_t;

/* Event manager type */
typedef struct vlc_event_manager_t
{
    void * p_obj;
    vlc_mutex_t object_lock;
    vlc_mutex_t event_sending_lock;
    vlc_object_t *p_parent_object;
    DECL_ARRAY(struct vlc_event_listeners_group_t *) listeners_groups;
} vlc_event_manager_t;

/* List of event */
/* Be sure to keep sync-ed with misc/events.c debug name table */
typedef enum vlc_event_type_t {
    /* Input (thread) events */
    vlc_InputStateChanged,

    /* Input item events */
    vlc_InputItemMetaChanged,
    vlc_InputItemSubItemAdded,
    vlc_InputItemDurationChanged,
    vlc_InputItemPreparsedChanged,
    vlc_InputItemNameChanged,
    vlc_InputItemInfoChanged,

    /* Service Discovery event */
    vlc_ServicesDiscoveryItemAdded,
    vlc_ServicesDiscoveryItemRemoved,
    vlc_ServicesDiscoveryStarted,
    vlc_ServicesDiscoveryEnded
} vlc_event_type_t;

/* Event definition */
typedef struct vlc_event_t
{
    vlc_event_type_t type;
    void * p_obj; /* Sender object, automatically filled by vlc_event_send() */
    union vlc_event_type_specific
    {
        /* Input (thread) events */
        struct vlc_input_state_changed
        {
            input_state_e new_state;
        } input_state_changed;

        /* Input item events */
        struct vlc_input_item_meta_changed
        {
            vlc_meta_type_t meta_type;
        } input_item_meta_changed;
        struct vlc_input_item_subitem_added
        {
            input_item_t * p_new_child;
        } input_item_subitem_added;<commit_msg>Revert "events: use input_state_e in input_state_changed."<commit_after>/*****************************************************************************
 * events.h: events definitions
 * Interface used to send events.
 *****************************************************************************
 * Copyright (C) 2007 the VideoLAN team
 * $Id$
 *
 * Authors: <NAME>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

#ifndef VLC_EVENTS_H
# define VLC_EVENTS_H

#include <vlc_arrays.h>
#include <vlc_meta.h>

/**
 * \file
 * This file is the interface definition for events
 * (implementation in src/misc/events.c)
 */

/*****************************************************************************
 * Documentation
 *****************************************************************************/
/*
 **** Background
 *
 * This implements a way to send and receive event for an object (which can be
 * a simple C struct or less).
 *
 * This is in direct concurrency with the Variable based Callback
 * (see src/misc/variables.c).
 *
 * It has the following advantages over Variable based Callback:
 * - No need to implement the whole VLC_COMMON_MEMBERS in the object,
 * thus it reduce it size. This is especially true for input_item_t which
 * doesn't have VLC_COMMON_MEMBERS. This is the first reason of existence of
 * this implementation.
 * - Libvlc can easily be based upon that.
 * - Existing event are clearly declared (in include/vlc_events.h)
 *
 *
 **** Example usage
 *
 * (vlc_cool_object_t doesn't need to have the VLC_COMMON_MEMBERS.)
 *
 * struct vlc_cool_object_t
 * {
 *        ...
 *        vlc_event_manager_t p_event_manager;
 *        ...
 * }
 *
 * vlc_my_cool_object_new()
 * {
 *        ...
 *        vlc_event_manager_init( &p_self->p_event_manager, p_self, p_a_libvlc_object );
 *        vlc_event_manager_register_event_type(p_self->p_event_manager,
 *                vlc_MyCoolObjectDidSomething, p_e)
 *        ...
 * }
 *
 * vlc_my_cool_object_release()
 * {
 *         ...
 *         vlc_event_manager_fini( &p_self->p_event_manager );
 *         ...
 * }
 *
 * vlc_my_cool_object_do_something()
 * {
 *        ...
 *        vlc_event_t event;
 *        event.type = vlc_MyCoolObjectDidSomething;
 *        event.u.my_cool_object_did_something.what_it_did = kSomething;
 *        vlc_event_send( &p_self->p_event_manager, &event );
 * }
 * */

  /*****************************************************************************
 * Event Type
 *****************************************************************************/

/* Private structure defined in misc/events.c */
struct vlc_event_listeners_group_t;

/* Event manager type */
typedef struct vlc_event_manager_t
{
    void * p_obj;
    vlc_mutex_t object_lock;
    vlc_mutex_t event_sending_lock;
    vlc_object_t *p_parent_object;
    DECL_ARRAY(struct vlc_event_listeners_group_t *) listeners_groups;
} vlc_event_manager_t;

/* List of event */
/* Be sure to keep sync-ed with misc/events.c debug name table */
typedef enum vlc_event_type_t {
    /* Input (thread) events */
    vlc_InputStateChanged,

    /* Input item events */
    vlc_InputItemMetaChanged,
    vlc_InputItemSubItemAdded,
    vlc_InputItemDurationChanged,
    vlc_InputItemPreparsedChanged,
    vlc_InputItemNameChanged,
    vlc_InputItemInfoChanged,

    /* Service Discovery event */
    vlc_ServicesDiscoveryItemAdded,
    vlc_ServicesDiscoveryItemRemoved,
    vlc_ServicesDiscoveryStarted,
    vlc_ServicesDiscoveryEnded
} vlc_event_type_t;

/* Event definition */
typedef struct vlc_event_t
{
    vlc_event_type_t type;
    void * p_obj; /* Sender object, automatically filled by vlc_event_send() */
    union vlc_event_type_specific
    {
        /* Input (thread) events */
        struct vlc_input_state_changed
        {
            int new_state;
        } input_state_changed;

        /* Input item events */
        struct vlc_input_item_meta_changed
        {
            vlc_meta_type_t meta_type;
        } input_item_meta_changed;
        struct vlc_input_item_subitem_added
        {
            input_item_t * p_new_child;
        } input_item_subitem_added;
{'fraction_non_alphanumeric': 0.18312609187133902, 'fraction_numerical': 0.003288459562223821, 'mean_word_length': 3.5668700140778977, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5962581', 'n_tokens_mistral': 2913, 'n_tokens_neox': 2763, 'n_words': 764}