-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMyFrameGeneratorInterface.cpp
70 lines (56 loc) · 2.16 KB
/
MyFrameGeneratorInterface.cpp
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
#ifndef _DEBUG
#include "MyFrameGeneratorInterface.h"
#include "MediaSoupTransceiver.h"
#include "MediaSoupMailbox.h"
MyFrameGeneratorInterface::MyFrameGeneratorInterface(int width, int height, OutputType type, std::shared_ptr<MediaSoupMailbox> mailbox)
: m_mailbox(mailbox), m_width(width), m_height(height)
{
m_lastFrame = webrtc::I420Buffer::Create(width, height);
webrtc::I420Buffer::SetBlack(m_lastFrame.get());
}
void MyFrameGeneratorInterface::ChangeResolution(size_t width, size_t height) {}
webrtc::test::FrameGeneratorInterface::Resolution MyFrameGeneratorInterface::GetResolution() const
{
return {static_cast<size_t>(m_width), static_cast<size_t>(m_height)};
}
webrtc::test::FrameGeneratorInterface::VideoFrameData MyFrameGeneratorInterface::NextFrame()
{
std::vector<rtc::scoped_refptr<webrtc::I420Buffer>> frames;
m_mailbox->pop_outgoing_videoFrames(frames);
if (!frames.empty())
m_lastFrame = frames[frames.size() - 1];
return VideoFrameData(m_lastFrame, absl::nullopt);
}
absl::optional<int> MyFrameGeneratorInterface::fps() const
{
return absl::nullopt;
}
FrameGeneratorCapturerVideoTrackSource::FrameGeneratorCapturerVideoTrackSource(Config config, webrtc::Clock *clock, bool is_screencast,
std::shared_ptr<MediaSoupMailbox> mailbox)
: VideoTrackSource(false), task_queue_factory_(webrtc::CreateDefaultTaskQueueFactory()), is_screencast_(is_screencast)
{
video_capturer_ = std::make_unique<webrtc::test::FrameGeneratorCapturer>(
clock,
std::make_unique<MyFrameGeneratorInterface>(config.width, config.height, webrtc::test::FrameGeneratorInterface::OutputType::kI420, mailbox),
config.frames_per_second, *task_queue_factory_);
video_capturer_->Init();
}
FrameGeneratorCapturerVideoTrackSource::~FrameGeneratorCapturerVideoTrackSource() {}
void FrameGeneratorCapturerVideoTrackSource::Start()
{
SetState(kLive);
}
void FrameGeneratorCapturerVideoTrackSource::Stop()
{
SetState(kEnded);
video_capturer_->Stop();
}
bool FrameGeneratorCapturerVideoTrackSource::is_screencast() const
{
return is_screencast_;
}
rtc::VideoSourceInterface<webrtc::VideoFrame> *FrameGeneratorCapturerVideoTrackSource::source()
{
return video_capturer_.get();
}
#endif