-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMediaSoupInterface.h
81 lines (66 loc) · 2.42 KB
/
MediaSoupInterface.h
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
71
72
73
74
75
76
77
78
79
80
81
#pragma once
#include "MediaSoupTransceiver.h"
#include <obs.h>
#include <mutex>
/**
* MediaSoupInterface
*/
class MediaSoupInterface {
public:
struct ObsSourceInfo {
obs_source_t *m_obs_source{nullptr};
gs_texture_t *m_obs_scene_texture{nullptr};
std::string m_consumer_audio;
std::string m_consumer_video;
int m_textureWidth = 0;
int m_textureHeight = 0;
};
public:
void reset();
void joinWaitingThread();
void resetThreadCache();
void setDataReadyForConnect(const std::string &val);
void setDataReadyForProduce(const std::string &val);
void setProduceParams(const std::string &val);
void setConnectParams(const std::string &val);
void setConnectIsWaiting(const bool v) { m_connectWaiting = v; }
void setProduceIsWaiting(const bool v) { m_produceWaiting = v; }
void setThreadIsProgress(const bool v) { m_threadInProgress = v; }
void setExpectingProduceFollowup(const bool v) { m_expectingProduceFollowup = v; }
void setConnectionThread(std::unique_ptr<std::thread> thr) { m_connectionThread = std::move(thr); }
static void applyVideoFrameToObsTexture(webrtc::VideoFrame &frame, ObsSourceInfo &sourceInfo);
static void ensureDrawTexture(const int width, const int height, ObsSourceInfo &sourceInfo);
bool popDataReadyForConnect(std::string &output);
bool popDataReadyForProduce(std::string &output);
bool popConnectParams(std::string &output);
bool popProduceParams(std::string &output);
bool isThreadInProgress() const { return m_threadInProgress; }
bool isConnectWaiting() const { return m_connectWaiting; }
bool isProduceWaiting() const { return m_produceWaiting; }
bool isExpectingProduceFollowup() { return m_expectingProduceFollowup; }
static int getHardObsTextureWidth() { return 1280; }
static int getHardObsTextureHeight() { return 720; }
MediaSoupTransceiver *getTransceiver() { return m_transceiver.get(); }
std::atomic<int> m_sourceCounter;
private:
bool m_threadInProgress{false};
bool m_connectWaiting{false};
bool m_produceWaiting{false};
bool m_expectingProduceFollowup{false};
std::mutex m_dataReadyMtx;
std::string m_dataReadyForConnect;
std::string m_dataReadyForProduce;
std::string m_produce_params;
std::string m_connect_params;
std::unique_ptr<MediaSoupTransceiver> m_transceiver;
std::unique_ptr<std::thread> m_connectionThread;
public:
static MediaSoupInterface &instance()
{
static MediaSoupInterface s;
return s;
}
private:
MediaSoupInterface();
~MediaSoupInterface();
};