hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
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
#ifndef RTSP_SENDER_NODE_
#define RTSP_SENDER_NODE_
 
#include <liveMedia.hh>
#include <BasicUsageEnvironment.hh>
#include <GroupsockHelper.hh>
#include <thread>
 
#include "CamCaptureHelper.h"
#include "RKHWEncApi.h"
 
class RtspServer
{
  public:
    RtspServer();
    ~RtspServer();
 
    typedef struct {
        char dev_name[64];    // camera v4l2 device name
        int width;            // camera v4l2 vfmt width
        int height;           // camera v4l2 vfmt height
        char stream_name[64]; // rtsp url stream name
        int port_num;         // rtsp port number
    } MetaInfo;
 
    bool init(MetaInfo* meta);
 
    void setDoneFlag()
    {
        fDoneFlag = ~0;
    }
    void resetDoneFlag()
    {
        fDoneFlag = 0;
    }
    void doEventLoop();
 
    bool start();
    bool stop();
 
    // It is called every time sent occurs.
    void onDoGetNextFrame(QMediaBuffer* outBuf);
 
  private:
    UsageEnvironment* mEnv;
    ServerMediaSession* mSms;
    RTSPServer* mRtspServer;
    char mStreamName[64];
 
    char fDoneFlag;
 
    std::thread* mProcThread;
 
    CamCaptureHelper* mCamDev;
    RKHWEncApi* mEncoder;
 
    bool initOther(MetaInfo* meta);
};
 
int init_rtsp(const char* video_dev, int width, int height);
void deinit_rtsp();
 
#endif // RTSP_SENDER_NODE_