summaryrefslogtreecommitdiff
path: root/libs/surfaces/websockets/ardour_websockets.h
blob: 40ee72aa884a41ef8f2319ddc023dba4755f9b55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
 * Copyright (C) 2009-2011 Carl Hetherington <carl@carlh.net>
 * Copyright (C) 2009-2017 Paul Davis <paul@linuxaudiosystems.com>
 * Copyright (C) 2009 David Robillard <d@drobilla.net>
 * Copyright (C) 2013-2016 Robin Gareus <robin@gareus.org>
 * Copyright (C) 2015 Johannes Mueller <github@johannes-mueller.org>
 * Copyright (C) 2016-2018 Len Ovens <len@ovenwerks.net>
 * Copyright (C) 2016 Ben Loftis <ben@harrisonconsoles.com>
 * Copyright (C) 2020 Luciano Iam <lucianito@gmail.com>
 
 * 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 _ardour_surface_websockets_h_
#define _ardour_surface_websockets_h_

#define ABSTRACT_UI_EXPORTS
#include "pbd/abstract_ui.h"

#include "ardour/plugin.h"
#include "control_protocol/control_protocol.h"

#include "component.h"
#include "dispatcher.h"
#include "feedback.h"
#include "globals.h"
#include "server.h"
#include "strips.h"

#define SURFACE_NAME "WebSockets Server (Experimental)"
#define SURFACE_ID   "uri://ardour.org/surfaces/ardour_websockets:0"

namespace ArdourSurface
{
struct ArdourWebsocketsUIRequest : public BaseUI::BaseRequestObject {
public:
	ArdourWebsocketsUIRequest () {}
	~ArdourWebsocketsUIRequest () {}
};

class ArdourWebsockets : public ARDOUR::ControlProtocol,
                         public AbstractUI<ArdourWebsocketsUIRequest>
{
public:
	ArdourWebsockets (ARDOUR::Session&);
	virtual ~ArdourWebsockets ();

	static void* request_factory (uint32_t);

	int set_active (bool);

	ARDOUR::Session& ardour_session ()
	{
		return *session;
	}
	ArdourStrips& strips_component ()
	{
		return _strips;
	}
	ArdourGlobals& globals_component ()
	{
		return _globals;
	}
	WebsocketsServer& server_component ()
	{
		return _server;
	}
	WebsocketsDispatcher& dispatcher_component ()
	{
		return _dispatcher;
	}

	/* ControlProtocol */
	void stripable_selection_changed () {}

protected:
	/* BaseUI */
	void thread_init ();

	/* AbstractUI */
	void do_request (ArdourWebsocketsUIRequest*);

private:
	ArdourStrips                   _strips;
	ArdourGlobals                  _globals;
	ArdourFeedback                 _feedback;
	WebsocketsServer               _server;
	WebsocketsDispatcher           _dispatcher;
	std::vector<SurfaceComponent*> _components;

	int start ();
	int stop ();
};

} // namespace ArdourSurface

#endif // ardour_websockets_h