Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
basic_control_endpoint.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022 Roc Streaming authors
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  */
8 
9 //! @file roc_ctl/basic_control_endpoint.h
10 //! @brief Base class for control endpoints.
11 
12 #ifndef ROC_CTL_BASIC_CONTROL_ENDPOINT_H_
13 #define ROC_CTL_BASIC_CONTROL_ENDPOINT_H_
14 
16 #include "roc_core/list_node.h"
17 #include "roc_core/ref_counted.h"
18 #include "roc_ctl/control_task.h"
21 
22 namespace roc {
23 namespace ctl {
24 
25 //! Base class for control endpoints.
27  : public core::RefCounted<BasicControlEndpoint, core::ArenaAllocation>,
28  public core::ListNode<> {
29 public:
30  //! Initialization.
32 
33  virtual ~BasicControlEndpoint();
34 
35  //! Check if endpoint is successfully bound to local URI.
36  virtual bool is_bound() const = 0;
37 
38  //! Check if endpoint is successfully connected to remote URI.
39  virtual bool is_connected() const = 0;
40 
41  //! Initiate asynchronous binding to local URI.
42  //! On completion, resumes @p notify_task.
43  virtual bool async_bind(const address::EndpointUri& uri,
44  ControlTask& notify_task) = 0;
45 
46  //! Initiate asynchronous connecting to remote URI.
47  //! Should be called after successfull bind.
48  //! On completion, resumes @p notify_task.
49  virtual bool async_connect(const address::EndpointUri& uri,
50  ControlTask& notify_task) = 0;
51 
52  //! Initiate asynchronous closing of endpoint.
53  //! On completion, resumes @p notify_task.
54  virtual void async_close(ControlTask& notify_task) = 0;
55 
56  //! Add sink pipeline controlled by this endpoint.
57  //! Should be called after successfull bind.
58  virtual bool attach_sink(const address::EndpointUri& uri,
59  pipeline::SenderLoop& sink) = 0;
60 
61  //! Remove sink pipeline.
62  //! Should be called for earlier attached sink.
63  virtual bool detach_sink(pipeline::SenderLoop& sink) = 0;
64 
65  //! Add source pipeline controlled by this endpoint.
66  //! Should be called after successfull bind.
67  virtual bool attach_source(const address::EndpointUri& uri,
68  pipeline::ReceiverLoop& source) = 0;
69 
70  //! Remove source pipeline.
71  //! Should be called for earlier attached source.
72  virtual bool detach_source(pipeline::ReceiverLoop& source) = 0;
73 };
74 
75 } // namespace ctl
76 } // namespace roc
77 
78 #endif // ROC_CTL_BASIC_CONTROL_ENDPOINT_H_
Network endpoint URI.
Definition: endpoint_uri.h:27
Memory arena interface.
Definition: iarena.h:23
Base class for List element.
Definition: list_node.h:48
Base class for object with reference counter.
Definition: ref_counted.h:40
Base class for control endpoints.
virtual bool detach_sink(pipeline::SenderLoop &sink)=0
Remove sink pipeline. Should be called for earlier attached sink.
virtual void async_close(ControlTask &notify_task)=0
Initiate asynchronous closing of endpoint. On completion, resumes notify_task.
virtual bool detach_source(pipeline::ReceiverLoop &source)=0
Remove source pipeline. Should be called for earlier attached source.
virtual bool is_bound() const =0
Check if endpoint is successfully bound to local URI.
virtual bool attach_sink(const address::EndpointUri &uri, pipeline::SenderLoop &sink)=0
Add sink pipeline controlled by this endpoint. Should be called after successfull bind.
virtual bool async_bind(const address::EndpointUri &uri, ControlTask &notify_task)=0
Initiate asynchronous binding to local URI. On completion, resumes notify_task.
BasicControlEndpoint(core::IArena &)
Initialization.
virtual bool async_connect(const address::EndpointUri &uri, ControlTask &notify_task)=0
Initiate asynchronous connecting to remote URI. Should be called after successfull bind....
virtual bool is_connected() const =0
Check if endpoint is successfully connected to remote URI.
virtual bool attach_source(const address::EndpointUri &uri, pipeline::ReceiverLoop &source)=0
Add source pipeline controlled by this endpoint. Should be called after successfull bind.
Base class for control tasks.
Definition: control_task.h:53
Receiver pipeline loop.
Definition: receiver_loop.h:46
Sender pipeline loop.
Definition: sender_loop.h:44
Control task.
Network endpoint URI.
Linked list node.
Root namespace.
Receiver pipeline loop.
Base class for object with reference counter.
Sender pipeline loop.