vlcplugin_base.h 4.08 KB
Newer Older
1
/*****************************************************************************
2
 * vlcplugin_base.h: a VLC plugin for Mozilla
3
 *****************************************************************************
4
 * Copyright (C) 2002-2012 VLC authors and VideoLAN
5 6 7 8 9
 * $Id$
 *
 * Authors: Samuel Hocevar <sam@zoy.org>
 *          Damien Fouilleul <damienf@videolan.org>
 *          Jean-Paul Saman <jpsaman@videolan.org>
10
 *          Sergey Radionov <rsatom@gmail.com>
11
 *          Cheng Sun <chengsun9@gmail.com>
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
 *
 * 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.
 *****************************************************************************/

/*******************************************************************************
 * Instance state information about the plugin.
 ******************************************************************************/
#ifndef __VLCPLUGIN_BASE_H__
#define __VLCPLUGIN_BASE_H__

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
34
#include "common.h"
35
#include "utils.hpp"
36 37

#include <vector>
38 39
#include <utility>
#include <unordered_map>
40

41
#include "../common/vlc_player_options.h"
42
#include "../common/vlc_player.h"
43

44 45
#define MAX_PARAMS 32

46 47 48 49 50 51 52 53 54 55 56 57
typedef enum vlc_toolbar_clicked_e {
    clicked_Unknown = 0,
    clicked_Play,
    clicked_Pause,
    clicked_Stop,
    clicked_timeline,
    clicked_Time,
    clicked_Fullscreen,
    clicked_Mute,
    clicked_Unmute
} vlc_toolbar_clicked_t;

58
class VlcPluginBase: private vlc_player_options
59 60 61 62 63 64 65
{
protected:

public:
    VlcPluginBase( NPP, NPuint16_t );
    virtual ~VlcPluginBase();

66 67 68 69 70
    vlc_player_options& get_options()
        { return *static_cast<vlc_player_options*>(this); }
    const vlc_player_options& get_options() const
        { return *static_cast<const vlc_player_options*>(this); }

71
    NPError             init(int argc, char* const argn[], char* const argv[]);
72

73
    VLC::MediaPlayer& getMD()
74
    {
75
        return m_player.get_mp();
76
    }
77 78

    NPP                 getBrowser() { return p_browser; };
79
    char*               getAbsoluteURL(const char *url);
80 81

    NPWindow&           getWindow()  { return npwindow; };
82
    virtual void        setWindow(const NPWindow &window);
83

84
    NPClass*            getScriptClass() { return p_scriptClass; };
85 86 87 88 89 90 91 92 93

    NPuint16_t  i_npmode; /* either NP_EMBED or NP_FULL */

    /* plugin properties */
    int      b_stream;
    char *   psz_target;

    void control_handler(vlc_toolbar_clicked_t);

94 95 96 97 98
    vlc_player& player()
    {
        return m_player;
    }

99 100 101 102
    virtual bool create_windows() = 0;
    virtual bool resize_windows() = 0;
    virtual bool destroy_windows() = 0;

103 104
    virtual bool handle_event(void *event);

105 106 107 108
#if defined(XP_MACOSX)
    virtual NPError get_root_layer(void *value);
#endif

109
    virtual void toggle_fullscreen() = 0;
110 111 112 113 114
    virtual void set_fullscreen(int) = 0;
    virtual int get_fullscreen() = 0;

    virtual void set_toolbar_visible(bool) = 0;
    virtual bool get_toolbar_visible() = 0;
115

116
    virtual void update_controls() = 0;
117
    virtual void popup_menu() = 0;
118

119 120
    virtual void set_player_window() = 0;

121 122
    static bool canUseEventListener();

123 124
    void subscribe(const char* eventName, npapi::Variant listener);
    void unsubscribe( const char* eventName, npapi::Variant listener );
125 126 127 128 129
protected:
    NPClass             *p_scriptClass;

    /* browser reference */
    NPP     p_browser;
130
    char    *psz_baseURL;
131 132 133 134

    /* display settings */
    NPWindow  npwindow;

135 136
    vlc_player m_player;

137 138
private:
    std::vector<std::tuple<std::string, NPObject*, VLC::EventManager::RegisteredEvent>> m_events;
139 140 141
};

#endif