-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathin_meeting_controller.cc
76 lines (58 loc) · 2.31 KB
/
in_meeting_controller.cc
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
#include "in_meeting_controller.hh"
#include <spdlog/spdlog.h>
#include "window_manager.hh"
VideoViewController::VideoViewController(std::shared_ptr<StreamPuller> puller, VideoView* view)
: puller_(puller), view_(view) {
puller_->RegisterListener(this);
}
VideoViewController::~VideoViewController() {
puller_->UnRegisterListener(this);
}
void VideoViewController::OnPullFrame(const std::string& user_id, MediaType media_type, std::shared_ptr<AVFRAME> frame) {
view_->OnFrame(frame);
}
InMeetingController::InMeetingController(InMeetingView* view)
: view_(view) {
MeetingModel::getInstance().Register(this);
view_->UpdateTitle(MeetingModel::getInstance().GetSelfUserId(), MeetingModel::getInstance().GetMeetingId());
}
InMeetingController::~InMeetingController() {
MeetingModel::getInstance().UnRegister(this);
}
void InMeetingController::HandleVideoClick() {
MeetingModel::getInstance().EnableMedia(kMediaTypeVideo, true);
}
void InMeetingController::HandleMeetingInfomationClick() {
view_->UpdateMeeingInfoToClipboard(MeetingModel::getInstance().GetMeetingId());
view_->ShowToast("Meeting information copied to clipboard.");
}
void InMeetingController::HandleExitClick() {
MeetingModel::getInstance().ExitMeeting();
}
void InMeetingController::PushMediaComplete(MediaType media_type, PushMediaResult result, const std::string& msg) {
}
void InMeetingController::OnUserStatusUpdate(const std::vector<UserStatus>& user_status) {
bool has_video_stream = false;
std::vector<std::shared_ptr<StreamPuller>> stream_pullers(user_status.size());
for (int i = 0; i < user_status.size(); ++i) {
auto us = user_status[i];
if (us.is_video_on) {
has_video_stream = true;
// todo: 用户可能既开视频又开共享,这一块逻辑需要处理
stream_pullers[i] = MeetingModel::getInstance().GetStreamPuller(us.user_id, kMediaTypeVideo);
}
}
if (has_video_stream) {
view_->UpdateVideoViews(user_status, stream_pullers);
} else {
view_->UpdateUserInfoViews(user_status);
}
}
void InMeetingController::LeaveMeetingComplete(LeaveMeetingResult result, const std::string& msg) {
if (result == kLeaveMeetingResultSuccess) {
WindowManager::getInstance().PushPremeetingView();
WindowManager::getInstance().PopInmeetingView();
} else {
view_->ShowToast(msg);
}
}