mf
Media Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
sync_node.h
Go to the documentation of this file.
1 #ifndef MF_FLOW_SYNC_NODE_H_
2 #define MF_FLOW_SYNC_NODE_H_
3 
4 #include <memory>
5 #include "filter_node.h"
6 #include "../queue/frame.h"
7 #include "../queue/timed_ring.h"
8 
9 namespace mf { namespace flow {
10 
11 class sync_node;
12 
13 
14 class sync_node_output : public node_output {
15 private:
16  std::unique_ptr<timed_ring> ring_;
17 
18 public:
20 
22 
23  void setup() override;
24 
27  void pull(time_span) override;
28  timed_frame_array_view begin_read(time_unit duration) override;
29  void end_read(time_unit duration) override;
30  time_unit end_time() const override;
32 
36  void end_write_frame(bool was_last_frame) override;
37  void cancel_write_frame() override;
39 };
40 
41 
43 
44 class sync_node final : public filter_node {
45 public:
46  explicit sync_node(graph& gr) : filter_node(gr) { }
47 
48  void internal_setup() final override;
49  void launch() final override;
50  void stop() final override;
51 
52  bool process_next_frame() override;
53 
54  node_input& add_input(time_unit past_window, time_unit future_window) override {
55  return add_input_<node_input>(past_window, future_window);
56  }
57 
58  sync_node_output& add_output(const frame_format& format) override {
59  return add_output_<sync_node_output>(format);
60  }
61 };
62 
63 
64 }}
65 
66 #endif
Input port of node in flow graph.
Definition: node.h:166
Generic ndarray_view where lower dimension(s) are type-erased.
Definition: ndarray_view_generic.h:25
Output port of node in flow graph.
Definition: node.h:108
Synchronous node base class.
Definition: sync_node.h:44
std::ptrdiff_t time_unit
Discrete time unit type.
Definition: common.h:52
node_output(const node_output &)=delete
void cancel_write_frame() override
Definition: sync_node.cc:131
void end_write_frame(bool was_last_frame) override
Definition: sync_node.cc:126
frame_view begin_write_frame(time_unit &t) override
Definition: sync_node.cc:119
void pull(time_span) override
Definition: sync_node.cc:85
bool process_next_frame() override
Definition: sync_node.cc:17
Node which delegates concrete frame processing to associated filter object.
Definition: filter_node.h:15
void internal_setup() finaloverride
Called by propagate_setup_.
Definition: sync_node.cc:6
timed_frame_array_view begin_read(time_unit duration) override
Definition: sync_node.cc:97
void setup() override
Definition: sync_node.cc:74
node_input & add_input(time_unit past_window, time_unit future_window) override
Definition: sync_node.h:54
void launch() finaloverride
Called by graph for all nodes, before any frame is pulled from sink.
Definition: sync_node.cc:12
sync_node(graph &gr)
Definition: sync_node.h:46
void end_read(time_unit duration) override
Definition: sync_node.cc:109
time_unit end_time() const override
Definition: sync_node.cc:114
One-dimensional time span.
Definition: common.h:61
Definition: sync_node.h:14
sync_node_output & add_output(const frame_format &format) override
Definition: sync_node.h:58
void stop() finaloverride
Called by graph for all node, before destruction of any node.
Definition: sync_node.cc:14
Generic ndarray_timed_view where lower dimension(s) are type-erased.
Definition: ndarray_timed_view_generic.h:12
Graph containing interconnected nodes through which media frames flow.
Definition: graph.h:23
Format information of type-erased frame of ndarray_view_generic.
Definition: frame_format.h:14