mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 12:45:35 +08:00
[feat] implementation for ScreenCapturerSck::Destroy() and ScreenCapturerSck::Stop()
This commit is contained in:
@@ -19,15 +19,24 @@ int ScreenCapturerSck::Init(const int fps, cb_desktop_data cb) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ScreenCapturerSck::Destroy() { return 0; }
|
||||
|
||||
int ScreenCapturerSck::Start() {
|
||||
screen_capturer_sck_impl_->Start();
|
||||
|
||||
int ScreenCapturerSck::Destroy() {
|
||||
if (screen_capturer_sck_impl_) {
|
||||
screen_capturer_sck_impl_->Destroy();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ScreenCapturerSck::Stop() { return 0; }
|
||||
int ScreenCapturerSck::Start() {
|
||||
screen_capturer_sck_impl_->Start();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ScreenCapturerSck::Stop() {
|
||||
if (screen_capturer_sck_impl_) {
|
||||
screen_capturer_sck_impl_->Stop();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ScreenCapturerSck::Pause(int monitor_index) {
|
||||
if (screen_capturer_sck_impl_) {
|
||||
|
||||
@@ -58,9 +58,9 @@ class API_AVAILABLE(macos(14.0)) ScreenCapturerSckImpl : public ScreenCapturer {
|
||||
|
||||
int SwitchTo(int monitor_index) override;
|
||||
|
||||
int Destroy() override { return 0; }
|
||||
int Destroy() override;
|
||||
|
||||
int Stop() override { return 0; }
|
||||
int Stop() override;
|
||||
|
||||
int Pause(int monitor_index) override { return 0; }
|
||||
|
||||
@@ -263,6 +263,35 @@ int ScreenCapturerSckImpl::SwitchTo(int monitor_index) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ScreenCapturerSckImpl::Destroy() {
|
||||
std::lock_guard<std::mutex> lock(lock_);
|
||||
if (stream_) {
|
||||
LOG_INFO("Destroying stream");
|
||||
[stream_ stopCaptureWithCompletionHandler:nil];
|
||||
stream_ = nil;
|
||||
}
|
||||
current_display_ = 0;
|
||||
permanent_error_ = false;
|
||||
_on_data = nullptr;
|
||||
[helper_ releaseCapturer];
|
||||
helper_ = nil;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ScreenCapturerSckImpl::Stop() {
|
||||
[stream_ stopCaptureWithCompletionHandler:nil];
|
||||
std::lock_guard<std::mutex> lock(lock_);
|
||||
if (stream_) {
|
||||
LOG_INFO("Stopping stream");
|
||||
[stream_ stopCaptureWithCompletionHandler:nil];
|
||||
stream_ = nil;
|
||||
}
|
||||
current_display_ = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ScreenCapturerSckImpl::OnShareableContentCreated(SCShareableContent *content) {
|
||||
if (!content) {
|
||||
LOG_ERROR("getShareableContent failed");
|
||||
|
||||
Reference in New Issue
Block a user