MCPcopy Create free account
hub / github.com/RGAA-Software/GoDesk / Encode

Method Encode

src/render/app/encoder_thread.cpp:62–470  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60 }
61
62 void EncoderThread::Encode(const CaptureVideoFrame& cap_video_msg) {
63 if (!frame_carrier_plugin_) {
64 return;
65 }
66 PostEncTask([=, this]() {
67 if (clear_encoders_) {
68 clear_encoders_ = false;
69 LOGW("clear all encoders!!!");
70 encoder_plugins_.clear();
71 }
72
73 auto adapter_uid = cap_video_msg.adapter_uid_;
74
75 // plugins: SharedTexture
76 if (cap_video_msg.handle_ > 0) {
77
78 // all plugins // to do 这里要不要考虑adapter_uid不合法的情况
79 //plugin_manager_->VisitAllPlugins([=, this](GrPluginInterface* plugin) {
80 // plugin->d3d11_devices_[adapter_uid] = app_->GetD3DDevice(adapter_uid);
81 // plugin->d3d11_devices_context_[adapter_uid] = app_->GetD3DContext(adapter_uid);
82 //});
83
84 context_->PostStreamPluginTask([=, this]() {
85 plugin_manager_->VisitAllPlugins([=](GrPluginInterface* plugin) {
86 plugin->OnRawVideoFrameSharedTexture(cap_video_msg.display_name_,
87 cap_video_msg.frame_index_,
88 cap_video_msg.frame_width_,
89 cap_video_msg.frame_height_,
90 cap_video_msg.handle_,
91 cap_video_msg.adapter_uid_,
92 cap_video_msg.frame_format_
93 );
94 });
95 });
96 }
97
98 auto settings = RdSettings::Instance();
99 auto frame_index = cap_video_msg.frame_index_;
100 //auto adapter_uid = cap_video_msg.adapter_uid_;
101 auto monitor_name = std::string(cap_video_msg.display_name_);
102 bool frame_meta_info_changed = [&]() {
103 auto last_video_frame_exists = last_video_frames_.contains(monitor_name);
104 if (!last_video_frame_exists) {
105 return true;
106 }
107 auto last_video_frame = last_video_frames_[monitor_name];
108 if (last_video_frame == std::nullopt) {
109 return true;
110 }
111 return last_video_frame.value().frame_width_ != cap_video_msg.frame_width_
112 || last_video_frame.value().frame_height_ != cap_video_msg.frame_height_;
113 }();
114
115 bool full_color_mode_changed = false;
116 auto target_encoder_plugin = GetEncoderPluginForMonitor(monitor_name);
117 if (target_encoder_plugin) {
118 auto encoder_config_res = target_encoder_plugin->GetEncoderConfig(monitor_name);
119 if (encoder_config_res.has_value()) {

Callers 3

InitAudioCaptureMethod · 0.45
OnIpcVideoFrameMethod · 0.45

Calls 15

PostStreamPluginTaskMethod · 0.80
EnableFullColorModeMethod · 0.80
GetD3DDeviceMethod · 0.80
GetD3DContextMethod · 0.80
InitFrameCarrierMethod · 0.80
GetNvencEncoderPluginMethod · 0.80
GetAmfEncoderPluginMethod · 0.80
VisitStreamPluginsMethod · 0.80
CopyTextureMethod · 0.80

Tested by

no test coverage detected