mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 16:46:35 +01:00
Namespace libwebsocket surface classes
Using the global names-pace for classes named "Json", "TypedValue", "ArdourTransport", "ArdourMixerPlugin" etc is not acceptable.
This commit is contained in:
parent
665e0686e5
commit
af79240c81
27 changed files with 88 additions and 17 deletions
|
|
@ -39,8 +39,8 @@
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "mixer.h"
|
#include "mixer.h"
|
||||||
|
|
||||||
namespace ArdourSurface
|
namespace ArdourSurface {
|
||||||
{
|
|
||||||
const char * const surface_name = "WebSockets Server (Experimental)";
|
const char * const surface_name = "WebSockets Server (Experimental)";
|
||||||
const char * const surface_id = "uri://ardour.org/surfaces/ardour_websockets:0";
|
const char * const surface_id = "uri://ardour.org/surfaces/ardour_websockets:0";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
|
||||||
|
using namespace ArdourSurface;
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ClientContext::has_state (const NodeState& node_state)
|
ClientContext::has_state (const NodeState& node_state)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,10 @@
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
|
|
||||||
typedef struct lws* Client;
|
typedef struct lws* Client;
|
||||||
|
|
||||||
|
namespace ArdourSurface {
|
||||||
|
|
||||||
typedef std::list<NodeStateMessage> ClientOutputBuffer;
|
typedef std::list<NodeStateMessage> ClientOutputBuffer;
|
||||||
|
|
||||||
class ClientContext
|
class ClientContext
|
||||||
|
|
@ -59,4 +62,6 @@ private:
|
||||||
ClientOutputBuffer _output_buf;
|
ClientOutputBuffer _output_buf;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace ArdourSurface
|
||||||
|
|
||||||
#endif // _ardour_surface_websockets_client_h_
|
#endif // _ardour_surface_websockets_client_h_
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@
|
||||||
#include "component.h"
|
#include "component.h"
|
||||||
#include "ardour_websockets.h"
|
#include "ardour_websockets.h"
|
||||||
|
|
||||||
|
using namespace ArdourSurface;
|
||||||
|
|
||||||
BasicUI&
|
BasicUI&
|
||||||
SurfaceComponent::basic_ui () const
|
SurfaceComponent::basic_ui () const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,8 @@
|
||||||
|
|
||||||
namespace ArdourSurface
|
namespace ArdourSurface
|
||||||
{
|
{
|
||||||
class ArdourWebsockets;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
class ArdourWebsockets;
|
||||||
class ArdourMixer;
|
class ArdourMixer;
|
||||||
class ArdourTransport;
|
class ArdourTransport;
|
||||||
class WebsocketsServer;
|
class WebsocketsServer;
|
||||||
|
|
@ -66,4 +65,6 @@ protected:
|
||||||
ArdourSurface::ArdourWebsockets& _surface;
|
ArdourSurface::ArdourWebsockets& _surface;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace ArdourSurface
|
||||||
|
|
||||||
#endif // _ardour_surface_websockets_component_h_
|
#endif // _ardour_surface_websockets_component_h_
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
|
|
||||||
using namespace ARDOUR;
|
using namespace ARDOUR;
|
||||||
|
using namespace ArdourSurface;
|
||||||
|
|
||||||
#define NODE_METHOD_PAIR(x) (Node::x, &WebsocketsDispatcher::x##_handler)
|
#define NODE_METHOD_PAIR(x) (Node::x, &WebsocketsDispatcher::x##_handler)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@
|
||||||
#include "component.h"
|
#include "component.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
|
|
||||||
|
namespace ArdourSurface {
|
||||||
|
|
||||||
class WebsocketsDispatcher : public SurfaceComponent
|
class WebsocketsDispatcher : public SurfaceComponent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -57,4 +59,6 @@ private:
|
||||||
void update (Client, std::string, const AddressVector&, const ValueVector&);
|
void update (Client, std::string, const AddressVector&, const ValueVector&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace ArdourSurface
|
||||||
|
|
||||||
#endif // _ardour_surface_websockets_dispatcher_h_
|
#endif // _ardour_surface_websockets_dispatcher_h_
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
#define POLL_INTERVAL_MS 100
|
#define POLL_INTERVAL_MS 100
|
||||||
|
|
||||||
using namespace ARDOUR;
|
using namespace ARDOUR;
|
||||||
|
using namespace ArdourSurface;
|
||||||
|
|
||||||
struct TransportObserver {
|
struct TransportObserver {
|
||||||
void operator() (ArdourFeedback* p)
|
void operator() (ArdourFeedback* p)
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@
|
||||||
#include "typed_value.h"
|
#include "typed_value.h"
|
||||||
#include "mixer.h"
|
#include "mixer.h"
|
||||||
|
|
||||||
|
namespace ArdourSurface {
|
||||||
|
|
||||||
class ArdourFeedback : public SurfaceComponent
|
class ArdourFeedback : public SurfaceComponent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -54,4 +56,6 @@ private:
|
||||||
void observe_strip_plugins (uint32_t, ArdourMixerStrip::PluginMap&);
|
void observe_strip_plugins (uint32_t, ArdourMixerStrip::PluginMap&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace ArdourSurface
|
||||||
|
|
||||||
#endif // _ardour_surface_websockets_feedback_h_
|
#endif // _ardour_surface_websockets_feedback_h_
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,12 @@
|
||||||
|
|
||||||
#include "json.h"
|
#include "json.h"
|
||||||
|
|
||||||
|
using namespace ArdourSurface;
|
||||||
|
|
||||||
/* adapted from https://stackoverflow.com/questions/7724448/simple-json-string-escape-for-c
|
/* adapted from https://stackoverflow.com/questions/7724448/simple-json-string-escape-for-c
|
||||||
CC BY-SA 4.0 license */
|
CC BY-SA 4.0 license */
|
||||||
std::string
|
std::string
|
||||||
Json::escape (const std::string &s) {
|
WebSocketsJSON::escape (const std::string &s) {
|
||||||
std::ostringstream o;
|
std::ostringstream o;
|
||||||
|
|
||||||
for (std::string::const_iterator it = s.begin(); it != s.end(); ++it) {
|
for (std::string::const_iterator it = s.begin(); it != s.end(); ++it) {
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,13 @@
|
||||||
#ifndef _ardour_surface_websockets_json_h_
|
#ifndef _ardour_surface_websockets_json_h_
|
||||||
#define _ardour_surface_websockets_json_h_
|
#define _ardour_surface_websockets_json_h_
|
||||||
|
|
||||||
namespace Json
|
namespace ArdourSurface {
|
||||||
|
|
||||||
|
namespace WebSocketsJSON
|
||||||
{
|
{
|
||||||
std::string escape (const std::string&);
|
std::string escape (const std::string&);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace ArdourSurface
|
||||||
|
|
||||||
#endif // _ardour_surface_websockets_json_h_
|
#endif // _ardour_surface_websockets_json_h_
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@
|
||||||
#include "resources.h"
|
#include "resources.h"
|
||||||
#include "json.h"
|
#include "json.h"
|
||||||
|
|
||||||
|
using namespace ArdourSurface;
|
||||||
|
|
||||||
static const char* const manifest_filename = "manifest.xml";
|
static const char* const manifest_filename = "manifest.xml";
|
||||||
|
|
||||||
SurfaceManifest::SurfaceManifest (std::string path)
|
SurfaceManifest::SurfaceManifest (std::string path)
|
||||||
|
|
@ -77,10 +79,10 @@ SurfaceManifest::to_json ()
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|
||||||
ss << "{"
|
ss << "{"
|
||||||
<< "\"path\":\"" << Json::escape (Glib::path_get_basename (_path)) << "\""
|
<< "\"path\":\"" << WebSocketsJSON::escape (Glib::path_get_basename (_path)) << "\""
|
||||||
<< ",\"name\":\"" << Json::escape (_name) << "\""
|
<< ",\"name\":\"" << WebSocketsJSON::escape (_name) << "\""
|
||||||
<< ",\"description\":\"" << Json::escape (_description) << "\""
|
<< ",\"description\":\"" << WebSocketsJSON::escape (_description) << "\""
|
||||||
<< ",\"version\":\"" << Json::escape (_version) << "\""
|
<< ",\"version\":\"" << WebSocketsJSON::escape (_version) << "\""
|
||||||
<< "}";
|
<< "}";
|
||||||
|
|
||||||
return ss.str ();
|
return ss.str ();
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace ArdourSurface {
|
||||||
|
|
||||||
class SurfaceManifest
|
class SurfaceManifest
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -47,4 +49,6 @@ private:
|
||||||
std::string _version;
|
std::string _version;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace ArdourSurface
|
||||||
|
|
||||||
#endif // _ardour_surface_websockets_manifest_h_
|
#endif // _ardour_surface_websockets_manifest_h_
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,8 @@
|
||||||
#define JSON_INF 1.0e+128
|
#define JSON_INF 1.0e+128
|
||||||
#define JSON_INF_STR XSTR (JSON_INF)
|
#define JSON_INF_STR XSTR (JSON_INF)
|
||||||
|
|
||||||
|
using namespace ArdourSurface;
|
||||||
|
|
||||||
namespace pt = boost::property_tree;
|
namespace pt = boost::property_tree;
|
||||||
|
|
||||||
NodeStateMessage::NodeStateMessage (const NodeState& state)
|
NodeStateMessage::NodeStateMessage (const NodeState& state)
|
||||||
|
|
@ -167,7 +169,7 @@ NodeStateMessage::serialize (void* buf, size_t len) const
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TypedValue::String:
|
case TypedValue::String:
|
||||||
ss << '"' << Json::escape (static_cast<std::string> (val)) << '"';
|
ss << '"' << WebSocketsJSON::escape (static_cast<std::string> (val)) << '"';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@
|
||||||
|
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
|
|
||||||
|
namespace ArdourSurface {
|
||||||
|
|
||||||
class NodeStateMessage
|
class NodeStateMessage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -48,4 +50,6 @@ private:
|
||||||
NodeState _state;
|
NodeState _state;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace ArdourSurface
|
||||||
|
|
||||||
#endif // _ardour_surface_websockets_message_h_
|
#endif // _ardour_surface_websockets_message_h_
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
#include "mixer.h"
|
#include "mixer.h"
|
||||||
|
|
||||||
using namespace ARDOUR;
|
using namespace ARDOUR;
|
||||||
|
using namespace ArdourSurface;
|
||||||
|
|
||||||
ArdourMixerPlugin::ArdourMixerPlugin (boost::shared_ptr<ARDOUR::PluginInsert> insert)
|
ArdourMixerPlugin::ArdourMixerPlugin (boost::shared_ptr<ARDOUR::PluginInsert> insert)
|
||||||
: _insert (insert)
|
: _insert (insert)
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,11 @@
|
||||||
#include "component.h"
|
#include "component.h"
|
||||||
#include "typed_value.h"
|
#include "typed_value.h"
|
||||||
|
|
||||||
|
namespace ArdourSurface {
|
||||||
|
|
||||||
struct ArdourMixerNotFoundException : public virtual std::runtime_error
|
struct ArdourMixerNotFoundException : public virtual std::runtime_error
|
||||||
{
|
{
|
||||||
using std::runtime_error::runtime_error;
|
using std::runtime_error::runtime_error; // XXX!
|
||||||
};
|
};
|
||||||
|
|
||||||
class ArdourMixerPlugin
|
class ArdourMixerPlugin
|
||||||
|
|
@ -120,4 +122,6 @@ private:
|
||||||
Glib::Threads::Mutex _mutex;
|
Glib::Threads::Mutex _mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace ArdourSurface
|
||||||
|
|
||||||
#endif // _ardour_surface_websockets_mixer_h_
|
#endif // _ardour_surface_websockets_mixer_h_
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@
|
||||||
#include "resources.h"
|
#include "resources.h"
|
||||||
#include "json.h"
|
#include "json.h"
|
||||||
|
|
||||||
|
using namespace ArdourSurface;
|
||||||
|
|
||||||
static const char* const data_dir_env_var = "ARDOUR_WEBSURFACES_PATH";
|
static const char* const data_dir_env_var = "ARDOUR_WEBSURFACES_PATH";
|
||||||
static const char* const data_dir_name = "web_surfaces";
|
static const char* const data_dir_name = "web_surfaces";
|
||||||
static const char* const builtin_dir_name = "builtin";
|
static const char* const builtin_dir_name = "builtin";
|
||||||
|
|
@ -85,8 +87,8 @@ ServerResources::scan ()
|
||||||
SurfaceManifestVector builtin = read_manifests (builtin_dir_str);
|
SurfaceManifestVector builtin = read_manifests (builtin_dir_str);
|
||||||
|
|
||||||
ss << "[{"
|
ss << "[{"
|
||||||
<< "\"filesystemPath\":\"" << Json::escape (builtin_dir_str) << "\""
|
<< "\"filesystemPath\":\"" << WebSocketsJSON::escape (builtin_dir_str) << "\""
|
||||||
<< ",\"path\":\"" << Json::escape (builtin_dir_name) << "\""
|
<< ",\"path\":\"" << WebSocketsJSON::escape (builtin_dir_name) << "\""
|
||||||
<< ",\"surfaces\":"
|
<< ",\"surfaces\":"
|
||||||
<< "[";
|
<< "[";
|
||||||
|
|
||||||
|
|
@ -101,8 +103,8 @@ ServerResources::scan ()
|
||||||
SurfaceManifestVector user = read_manifests (user_dir_str);
|
SurfaceManifestVector user = read_manifests (user_dir_str);
|
||||||
|
|
||||||
ss << "]},{"
|
ss << "]},{"
|
||||||
<< "\"filesystemPath\":\"" << Json::escape (user_dir_str) << "\""
|
<< "\"filesystemPath\":\"" << WebSocketsJSON::escape (user_dir_str) << "\""
|
||||||
<< ",\"path\":\"" << Json::escape (user_dir_name) << "\""
|
<< ",\"path\":\"" << WebSocketsJSON::escape (user_dir_name) << "\""
|
||||||
<< ",\"surfaces\":"
|
<< ",\"surfaces\":"
|
||||||
<< "[";
|
<< "[";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@
|
||||||
|
|
||||||
#include "manifest.h"
|
#include "manifest.h"
|
||||||
|
|
||||||
|
namespace ArdourSurface {
|
||||||
|
|
||||||
typedef std::vector<SurfaceManifest> SurfaceManifestVector;
|
typedef std::vector<SurfaceManifest> SurfaceManifestVector;
|
||||||
|
|
||||||
class ServerResources
|
class ServerResources
|
||||||
|
|
@ -49,4 +51,6 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace ArdourSurface
|
||||||
|
|
||||||
#endif // _ardour_surface_websockets_resources_h_
|
#endif // _ardour_surface_websockets_resources_h_
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@
|
||||||
#define MAX_INDEX_SIZE 65536
|
#define MAX_INDEX_SIZE 65536
|
||||||
|
|
||||||
using namespace Glib;
|
using namespace Glib;
|
||||||
|
using namespace ArdourSurface;
|
||||||
|
|
||||||
WebsocketsServer::WebsocketsServer (ArdourSurface::ArdourWebsockets& surface)
|
WebsocketsServer::WebsocketsServer (ArdourSurface::ArdourWebsockets& surface)
|
||||||
: SurfaceComponent (surface)
|
: SurfaceComponent (surface)
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,8 @@ struct LwsPollFdGlibSource {
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace ArdourSurface {
|
||||||
|
|
||||||
class WebsocketsServer : public SurfaceComponent
|
class WebsocketsServer : public SurfaceComponent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -102,4 +104,6 @@ private:
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace ArdourSurface
|
||||||
|
|
||||||
#endif // _ardour_surface_websockets_server_h_
|
#endif // _ardour_surface_websockets_server_h_
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@
|
||||||
|
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
|
|
||||||
|
using namespace ArdourSurface;
|
||||||
|
|
||||||
NodeState::NodeState () {}
|
NodeState::NodeState () {}
|
||||||
|
|
||||||
NodeState::NodeState (std::string node)
|
NodeState::NodeState (std::string node)
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@
|
||||||
|
|
||||||
#define ADDR_NONE UINT_MAX
|
#define ADDR_NONE UINT_MAX
|
||||||
|
|
||||||
|
namespace ArdourSurface {
|
||||||
|
|
||||||
namespace Node
|
namespace Node
|
||||||
{
|
{
|
||||||
const std::string strip_description = "strip_description";
|
const std::string strip_description = "strip_description";
|
||||||
|
|
@ -84,4 +86,6 @@ private:
|
||||||
std::size_t
|
std::size_t
|
||||||
hash_value (const NodeState&);
|
hash_value (const NodeState&);
|
||||||
|
|
||||||
|
} // namespace ArdourSurface
|
||||||
|
|
||||||
#endif // _ardour_surface_websockets_state_h_
|
#endif // _ardour_surface_websockets_state_h_
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
#include "transport.h"
|
#include "transport.h"
|
||||||
|
|
||||||
using namespace ARDOUR;
|
using namespace ARDOUR;
|
||||||
|
using namespace ArdourSurface;
|
||||||
|
|
||||||
double
|
double
|
||||||
ArdourTransport::tempo () const
|
ArdourTransport::tempo () const
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@
|
||||||
|
|
||||||
#include "component.h"
|
#include "component.h"
|
||||||
|
|
||||||
|
namespace ArdourSurface {
|
||||||
|
|
||||||
class ArdourTransport : public SurfaceComponent
|
class ArdourTransport : public SurfaceComponent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -40,4 +42,6 @@ public:
|
||||||
void set_record (bool);
|
void set_record (bool);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace ArdourSurface
|
||||||
|
|
||||||
#endif // _ardour_surface_websockets_transport_h_
|
#endif // _ardour_surface_websockets_transport_h_
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@
|
||||||
|
|
||||||
#include "typed_value.h"
|
#include "typed_value.h"
|
||||||
|
|
||||||
|
using namespace ArdourSurface;
|
||||||
|
|
||||||
#define DBL_TOLERANCE 0.001
|
#define DBL_TOLERANCE 0.001
|
||||||
|
|
||||||
TypedValue::TypedValue ()
|
TypedValue::TypedValue ()
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@
|
||||||
#ifndef _ardour_surface_websockets_typed_value_h_
|
#ifndef _ardour_surface_websockets_typed_value_h_
|
||||||
#define _ardour_surface_websockets_typed_value_h_
|
#define _ardour_surface_websockets_typed_value_h_
|
||||||
|
|
||||||
|
namespace ArdourSurface {
|
||||||
|
|
||||||
class TypedValue
|
class TypedValue
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -65,4 +67,6 @@ private:
|
||||||
std::string _s;
|
std::string _s;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace ArdourSurface
|
||||||
|
|
||||||
#endif // _ardour_surface_websockets_typed_value_h_
|
#endif // _ardour_surface_websockets_typed_value_h_
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue