-
-
Notifications
You must be signed in to change notification settings - Fork 492
/
Copy pathVoipVideoCapture.cpp
90 lines (77 loc) · 2.25 KB
/
VoipVideoCapture.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "pch.h"
#include "VoipVideoCapture.h"
#if __has_include("VoipVideoCapture.g.cpp")
#include "VoipVideoCapture.g.cpp"
#endif
#include "VoipVideoOutputSink.h"
#include "StaticThreads.h"
#include "platform/uwp/UwpContext.h"
namespace winrt::Telegram::Native::Calls::implementation
{
VoipVideoCapture::VoipVideoCapture(hstring id)
{
m_impl = tgcalls::VideoCaptureInterface::Create(
tgcalls::StaticThreads::getThreads(),
winrt::to_string(id));
m_impl->setOnFatalError([this] {
m_failed = true;
m_fatalErrorOccurred(*this, nullptr);
});
}
void VoipVideoCapture::Stop()
{
m_impl.reset();
m_impl = nullptr;
}
void VoipVideoCapture::SwitchToDevice(hstring deviceId)
{
if (m_impl)
{
m_impl->switchToDevice(winrt::to_string(deviceId), false);
}
}
void VoipVideoCapture::SetState(VoipVideoState state)
{
if (m_impl)
{
m_impl->setState((tgcalls::VideoState)state);
}
}
void VoipVideoCapture::SetPreferredAspectRatio(float aspectRatio)
{
if (m_impl)
{
m_impl->setPreferredAspectRatio(aspectRatio);
}
}
void VoipVideoCapture::SetOutput(winrt::Telegram::Native::Calls::VoipVideoOutputSink sink)
{
if (m_impl)
{
if (sink != nullptr)
{
auto implementation = winrt::get_self<VoipVideoOutputSink>(sink);
m_impl->setOutput(implementation->Sink());
}
else
{
m_impl->setOutput(nullptr);
}
}
}
winrt::event_token VoipVideoCapture::FatalErrorOccurred(Windows::Foundation::TypedEventHandler<
winrt::Telegram::Native::Calls::VoipCaptureBase,
winrt::Windows::Foundation::IInspectable> const& value)
{
auto token = m_fatalErrorOccurred.add(value);
if (m_failed)
{
m_fatalErrorOccurred(*this, nullptr);
}
return token;
}
void VoipVideoCapture::FatalErrorOccurred(winrt::event_token const& token)
{
m_fatalErrorOccurred.remove(token);
}
} // namespace winrt::Telegram::Native::Calls::implementation