wangrong
2025-01-03 2c4b8838f89bebca97615c5f0bac2c58e0349771
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
#pragma once
 
#include "vp_node.h"
#include "vp_stream_info_hookable.h"
#include "../excepts/vp_not_implemented_error.h"
#include "../excepts/vp_invalid_calling_error.h"
#include "../utils/vp_gate.h"
 
namespace vp_nodes {
    // base class for src nodes, start point of meta/pipeline
    class vp_src_node: public vp_node, public vp_stream_info_hookable {
    private:
        /* data */
    
    protected:
        // force re-implemetation in child class
        virtual void handle_run() override;
        // force ignored in child class
        virtual std::shared_ptr<vp_objects::vp_meta> handle_frame_meta(std::shared_ptr<vp_objects::vp_frame_meta> meta) override; 
        // force ignored in child class
        virtual std::shared_ptr<vp_objects::vp_meta> handle_control_meta(std::shared_ptr<vp_objects::vp_control_meta> meta) override;
 
        // protected as it can't be instanstiated directly.
        vp_src_node(std::string node_name, 
                    int channel_index, 
                    float resize_ratio = 1.0);
 
        // basic stream info
        int original_fps = -1;
        int original_width = 0;
        int original_height = 0;
 
        // basic channel info
        int frame_index;
        int channel_index;
        float resize_ratio;
 
        // control to work or not
        // all derived class need depend on the value to check if work or not (start/stop)
        vp_utils::vp_gate gate;
 
        // new logic for sending dead flag
        virtual void deinitialized() override;
    public:
        ~vp_src_node();
 
        virtual vp_node_type node_type() override;
 
        // start signal to pipeline
        void start();
        // stop signal to pipeline
        void stop();
        // speak signal to the pipeline (each node print some message such as current status)
        void speak();
 
        /* Debug API */
        // record video signal to pipeline, start recording video when vp_record_node(if exists) receive the signal.
        // it is a debug api since record signal is usually generated automatically inside pipe(not by users outside pipe).
        void record_video_manually(bool osd = false, int video_duration = 10);
        /* Debug API */
        // record image signal to pipeline, start recording image when vp_record_node(if exists) receive the signal.
        // it is a debug api since record signal is usually generated automatically inside pipe(not by userd outside pipe).
        void record_image_manually(bool osd = false);
 
        int get_original_fps() const;
        int get_original_width() const;
        int get_original_height() const;
    };
    
}