-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMediaSoupMailbox.h
70 lines (53 loc) · 1.98 KB
/
MediaSoupMailbox.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
#pragma once
#include "MediaSoupTransceiver.h"
/**
* MediaSoupMailbox
*/
class MediaSoupMailbox {
public:
// 10ms frame
struct SoupSendAudioFrame {
std::vector<int16_t> audio_data;
int numFrames = 0;
int numChannels = 0;
int bytesPerSample = 0;
int samples_per_sec = 0;
};
public:
~MediaSoupMailbox();
rtc::scoped_refptr<webrtc::I420Buffer> getProducerFrameBuffer(const int width, const int height);
public:
// Receive
void push_received_videoFrame(std::unique_ptr<webrtc::VideoFrame> ptr);
void pop_receieved_videoFrames(std::unique_ptr<webrtc::VideoFrame> &output);
public:
// Outgoing
void push_outgoing_videoFrame(rtc::scoped_refptr<webrtc::I420Buffer>);
void pop_outgoing_videoFrames(std::vector<rtc::scoped_refptr<webrtc::I420Buffer>> &output);
void push_outgoing_audioFrame(const uint8_t **data, const int frames);
void pop_outgoing_audioFrames(std::vector<std::unique_ptr<SoupSendAudioFrame>> &output);
void assignOutgoingAudioParams(const audio_format audioformat, const speaker_layout speakerLayout, const int bytesPerSample, const int numChannels,
const int samples_per_sec);
void assignOutgoingVolume(const float vol) { m_volume = vol; }
private:
// Receive
std::mutex m_mtx_received_video;
std::unique_ptr<webrtc::VideoFrame> m_received_video_frame;
private:
// Outgoing
std::mutex m_mtx_outgoing_video;
std::mutex m_mtx_outgoing_audio;
std::vector<rtc::scoped_refptr<webrtc::I420Buffer>> m_outgoing_video_data;
std::vector<std::string> m_outgoing_audio_data;
int m_obs_bytesPerSample = 0;
int m_obs_numChannels = 0;
int m_obs_samples_per_sec = 0;
int m_obs_numFrames = 0;
float m_volume = 0;
audio_format m_obs_audioformat = AUDIO_FORMAT_UNKNOWN;
speaker_layout m_obs_speakerLayout = SPEAKERS_UNKNOWN;
audio_resampler_t *m_to_float_resampler = nullptr;
audio_resampler_t *m_from_float_to_mediasoup_resampler = nullptr;
audio_resampler_t *m_to_mediasoup_resampler = nullptr;
rtc::scoped_refptr<webrtc::I420Buffer> m_producerFrameBuffer;
};