From 2d9dfb1c58eec25c8d7f46125a02fb3b52c1e83b Mon Sep 17 00:00:00 2001 From: ling-feng-taixing <15996208704@163.com> Date: Fri, 15 Mar 2024 14:42:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=85=E6=A0=B8=E6=8E=A5=E5=8F=A3=E8=A7=A3?= =?UTF-8?q?=E8=80=A6--struct=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ling-feng-taixing <15996208704@163.com> Change-Id: Id395760ea1937f00dd8875236b96467d5072e2bf Signed-off-by: ling-feng-taixing <15996208704@163.com> --- modules/desktop_capture/BUILD.gn | 16 +++++ .../ohos/audio_capture_info_adapter_impl.cc | 44 ++++++++++++ .../ohos/audio_capture_info_adapter_impl.h | 51 ++++++++++++++ .../ohos/audio_enc_info_adapter_impl.cc | 37 ++++++++++ .../ohos/audio_enc_info_adapter_impl.h | 45 ++++++++++++ .../ohos/audio_info_adapter_impl.cc | 48 +++++++++++++ .../ohos/audio_info_adapter_impl.h | 51 ++++++++++++++ .../ohos/base_window_capturer.cc | 68 ++++++++++++------- .../ohos/recorder_info_adapter_impl.cc | 36 ++++++++++ .../ohos/recorder_info_adapter_impl.h | 45 ++++++++++++ .../screen_capture_config_adapter_impl.cc | 66 ++++++++++++++++++ .../ohos/screen_capture_config_adapter_impl.h | 58 ++++++++++++++++ .../ohos/video_capture_info_adapter_impl.cc | 60 ++++++++++++++++ .../ohos/video_capture_info_adapter_impl.h | 64 +++++++++++++++++ .../ohos/video_enc_info_adapter_impl.cc | 44 ++++++++++++ .../ohos/video_enc_info_adapter_impl.h | 50 ++++++++++++++ .../ohos/video_info_adapter_impl.cc | 38 +++++++++++ .../ohos/video_info_adapter_impl.h | 44 ++++++++++++ 18 files changed, 840 insertions(+), 25 deletions(-) create mode 100644 modules/desktop_capture/ohos/audio_capture_info_adapter_impl.cc create mode 100644 modules/desktop_capture/ohos/audio_capture_info_adapter_impl.h create mode 100644 modules/desktop_capture/ohos/audio_enc_info_adapter_impl.cc create mode 100644 modules/desktop_capture/ohos/audio_enc_info_adapter_impl.h create mode 100644 modules/desktop_capture/ohos/audio_info_adapter_impl.cc create mode 100644 modules/desktop_capture/ohos/audio_info_adapter_impl.h mode change 100755 => 100644 modules/desktop_capture/ohos/base_window_capturer.cc create mode 100644 modules/desktop_capture/ohos/recorder_info_adapter_impl.cc create mode 100644 modules/desktop_capture/ohos/recorder_info_adapter_impl.h create mode 100644 modules/desktop_capture/ohos/screen_capture_config_adapter_impl.cc create mode 100644 modules/desktop_capture/ohos/screen_capture_config_adapter_impl.h create mode 100644 modules/desktop_capture/ohos/video_capture_info_adapter_impl.cc create mode 100644 modules/desktop_capture/ohos/video_capture_info_adapter_impl.h create mode 100644 modules/desktop_capture/ohos/video_enc_info_adapter_impl.cc create mode 100644 modules/desktop_capture/ohos/video_enc_info_adapter_impl.h create mode 100644 modules/desktop_capture/ohos/video_info_adapter_impl.cc create mode 100644 modules/desktop_capture/ohos/video_info_adapter_impl.h diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn index 80612663..274af391 100644 --- a/modules/desktop_capture/BUILD.gn +++ b/modules/desktop_capture/BUILD.gn @@ -416,6 +416,22 @@ rtc_library("desktop_capture") { "window_capturer_ohos.cc", "ohos/base_window_capturer.cc", "ohos/base_window_capturer.h", + "ohos/audio_capture_info_adapter_impl.cc", + "ohos/audio_capture_info_adapter_impl.h", + "ohos/audio_enc_info_adapter_impl.cc", + "ohos/audio_enc_info_adapter_impl.h", + "ohos/audio_info_adapter_impl.cc", + "ohos/audio_info_adapter_impl.h", + "ohos/recorder_info_adapter_impl.cc", + "ohos/recorder_info_adapter_impl.h", + "ohos/screen_capture_config_adapter_impl.cc", + "ohos/screen_capture_config_adapter_impl.h", + "ohos/video_capture_info_adapter_impl.cc", + "ohos/video_capture_info_adapter_impl.h", + "ohos/video_enc_info_adapter_impl.cc", + "ohos/video_enc_info_adapter_impl.h", + "ohos/video_info_adapter_impl.cc", + "ohos/video_info_adapter_impl.h", ] include_dirs = ohos_src_includes deps += [ diff --git a/modules/desktop_capture/ohos/audio_capture_info_adapter_impl.cc b/modules/desktop_capture/ohos/audio_capture_info_adapter_impl.cc new file mode 100644 index 00000000..7ea04e36 --- /dev/null +++ b/modules/desktop_capture/ohos/audio_capture_info_adapter_impl.cc @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "audio_capture_info_adapter_impl.h" + +namespace OHOS::NWeb { +int32_t AudioCaptureInfoAdapterImpl::GetAudioSampleRate() { + return sample_rate_; +} + +int32_t AudioCaptureInfoAdapterImpl::GetAudioChannels() { + return channels_; +} + +AudioCaptureSourceTypeAdapter AudioCaptureInfoAdapterImpl::GetAudioSource() { + return source_; +} + +void AudioCaptureInfoAdapterImpl::SetAudioSampleRate(int32_t rate) { + sample_rate_ = rate; +} + +void AudioCaptureInfoAdapterImpl::SetAudioChannels(int32_t channel) { + channels_ = channel; +} + +void AudioCaptureInfoAdapterImpl::SetAudioSource( + AudioCaptureSourceTypeAdapter type) { + source_ = type; +} + +} // namespace OHOS::NWeb diff --git a/modules/desktop_capture/ohos/audio_capture_info_adapter_impl.h b/modules/desktop_capture/ohos/audio_capture_info_adapter_impl.h new file mode 100644 index 00000000..f0dd1da6 --- /dev/null +++ b/modules/desktop_capture/ohos/audio_capture_info_adapter_impl.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AUDIO_CAPTURE_INFO_ADAPTER_IMPL_H +#define AUDIO_CAPTURE_INFO_ADAPTER_IMPL_H + +#include "screen_capture_adapter.h" + +namespace OHOS::NWeb { + +class AudioCaptureInfoAdapterImpl : public AudioCaptureInfoAdapter { + public: + AudioCaptureInfoAdapterImpl() = default; + + int32_t GetAudioSampleRate() override; + + int32_t GetAudioChannels() override; + + AudioCaptureSourceTypeAdapter GetAudioSource() override; + + void SetAudioSampleRate(int32_t rate); + + void SetAudioChannels(int32_t channel); + + void SetAudioSource(AudioCaptureSourceTypeAdapter type); + + private: + /* Audio capture sample rate info */ + int32_t sample_rate_ = 0; + /* Audio capture channel info */ + int32_t channels_ = 0; + /* Audio capture source type */ + AudioCaptureSourceTypeAdapter source_ = + AudioCaptureSourceTypeAdapter::SOURCE_DEFAULT; +}; + +} // namespace OHOS::NWeb + +#endif // AUDIO_CAPTURE_INFO_ADAPTER_IMPL_H diff --git a/modules/desktop_capture/ohos/audio_enc_info_adapter_impl.cc b/modules/desktop_capture/ohos/audio_enc_info_adapter_impl.cc new file mode 100644 index 00000000..4813f390 --- /dev/null +++ b/modules/desktop_capture/ohos/audio_enc_info_adapter_impl.cc @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "audio_enc_info_adapter_impl.h" + +namespace OHOS::NWeb { + +int32_t AudioEncInfoAdapterImpl::GetAudioBitrate() { + return bitrate_; +} + +AudioCodecFormatAdapter AudioEncInfoAdapterImpl::GetAudioCodecformat() { + return codec_format_; +} + +void AudioEncInfoAdapterImpl::SetAudioBitrate(int32_t bitrate) { + bitrate_ = bitrate; +} + +void AudioEncInfoAdapterImpl::SetAudioCodecformat( + AudioCodecFormatAdapter format) { + codec_format_ = format; +} + +} // namespace OHOS::NWeb diff --git a/modules/desktop_capture/ohos/audio_enc_info_adapter_impl.h b/modules/desktop_capture/ohos/audio_enc_info_adapter_impl.h new file mode 100644 index 00000000..3a7fea69 --- /dev/null +++ b/modules/desktop_capture/ohos/audio_enc_info_adapter_impl.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AUDIO_ENC_INFO_ADAPTER_IMPL_H +#define AUDIO_ENC_INFO_ADAPTER_IMPL_H + +#include "screen_capture_adapter.h" + +namespace OHOS::NWeb { + +class AudioEncInfoAdapterImpl : public AudioEncInfoAdapter { + public: + AudioEncInfoAdapterImpl() = default; + + int32_t GetAudioBitrate() override; + + AudioCodecFormatAdapter GetAudioCodecformat() override; + + void SetAudioBitrate(int32_t bitrate); + + void SetAudioCodecformat(AudioCodecFormatAdapter format); + + private: + /* Audio encoder bitrate */ + int32_t bitrate_ = 0; + /* Audio codec format */ + AudioCodecFormatAdapter codec_format_ = + AudioCodecFormatAdapter::AUDIO_DEFAULT; +}; + +} // namespace OHOS::NWeb + +#endif // AUDIO_ENC_INFO_ADAPTER_IMPL_H diff --git a/modules/desktop_capture/ohos/audio_info_adapter_impl.cc b/modules/desktop_capture/ohos/audio_info_adapter_impl.cc new file mode 100644 index 00000000..32f05bdb --- /dev/null +++ b/modules/desktop_capture/ohos/audio_info_adapter_impl.cc @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "audio_info_adapter_impl.h" + +namespace OHOS::NWeb { + +std::shared_ptr AudioInfoAdapterImpl::GetMicCapInfo() { + return mic_cap_info_; +} + +std::shared_ptr +AudioInfoAdapterImpl::GetInnerCapInfo() { + return inner_cap_info_; +} + +std::shared_ptr AudioInfoAdapterImpl::GetAudioEncInfo() { + return enc_info_; +} + +void AudioInfoAdapterImpl::SetMicCapInfo( + std::shared_ptr info) { + mic_cap_info_ = info; +} + +void AudioInfoAdapterImpl::SetInnerCapInfo( + std::shared_ptr info) { + inner_cap_info_ = info; +} + +void AudioInfoAdapterImpl::SetAudioEncInfo( + std::shared_ptr info) { + enc_info_ = info; +} + +} // namespace OHOS::NWeb diff --git a/modules/desktop_capture/ohos/audio_info_adapter_impl.h b/modules/desktop_capture/ohos/audio_info_adapter_impl.h new file mode 100644 index 00000000..fa4369e4 --- /dev/null +++ b/modules/desktop_capture/ohos/audio_info_adapter_impl.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AUDIO_INFO_ADAPTER_IMPL_H +#define AUDIO_INFO_ADAPTER_IMPL_H + +#include "screen_capture_adapter.h" + +namespace OHOS::NWeb { + +class AudioInfoAdapterImpl : public AudioInfoAdapter { + public: + AudioInfoAdapterImpl() = default; + + std::shared_ptr GetMicCapInfo() override; + + std::shared_ptr GetInnerCapInfo() override; + + std::shared_ptr GetAudioEncInfo() override; + + void SetMicCapInfo(std::shared_ptr info); + + void SetInnerCapInfo(std::shared_ptr info); + + void SetAudioEncInfo(std::shared_ptr info); + + private: + /* Audio capture info of microphone */ + std::shared_ptr mic_cap_info_ = nullptr; + /* Audio capture info of inner */ + std::shared_ptr inner_cap_info_ = nullptr; + /* Audio encoder info, no need to set, while dataType = + * ORIGINAL_STREAM_DATA_TYPE */ + std::shared_ptr enc_info_ = nullptr; +}; + +} // namespace OHOS::NWeb + +#endif // AUDIO_INFO_ADAPTER_IMPL_H diff --git a/modules/desktop_capture/ohos/base_window_capturer.cc b/modules/desktop_capture/ohos/base_window_capturer.cc old mode 100755 new mode 100644 index 80e9bc6d..e75caf9e --- a/modules/desktop_capture/ohos/base_window_capturer.cc +++ b/modules/desktop_capture/ohos/base_window_capturer.cc @@ -21,19 +21,26 @@ #include "absl/memory/memory.h" #include "base/logging.h" +#include "base/memory/platform_shared_memory_region.h" +#include "base/memory/ptr_util.h" +#include "base/memory/read_only_shared_memory_region.h" #include "base/task/single_thread_task_runner.h" #include "modules/desktop_capture/desktop_capture_options.h" #include "modules/desktop_capture/desktop_capturer.h" +#include "modules/desktop_capture/ohos/audio_capture_info_adapter_impl.h" +#include "modules/desktop_capture/ohos/audio_enc_info_adapter_impl.h" +#include "modules/desktop_capture/ohos/audio_info_adapter_impl.h" +#include "modules/desktop_capture/ohos/recorder_info_adapter_impl.h" +#include "modules/desktop_capture/ohos/screen_capture_config_adapter_impl.h" +#include "modules/desktop_capture/ohos/video_capture_info_adapter_impl.h" +#include "modules/desktop_capture/ohos/video_enc_info_adapter_impl.h" +#include "modules/desktop_capture/ohos/video_info_adapter_impl.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/string_encode.h" #include "rtc_base/string_to_number.h" #include "rtc_base/time_utils.h" -#include "base/memory/platform_shared_memory_region.h" -#include "base/memory/ptr_util.h" -#include "base/memory/read_only_shared_memory_region.h" - namespace webrtc { namespace { constexpr int32_t kAudioSampleRate = 16000; @@ -179,26 +186,36 @@ BaseWindowCapturer::BaseWindowCapturer(CaptureSourceType source_type) LOG(ERROR) << "create screen capture adapter failed"; return; } - OHOS::NWeb::AudioCaptureInfoAdapter micCapInfo = { - .audioSampleRate = kAudioSampleRate, - .audioChannels = kAudioChannels, - .audioSource = OHOS::NWeb::AudioCaptureSourceTypeAdapter::SOURCE_DEFAULT - }; - OHOS::NWeb::AudioInfoAdapter audioInfo = {.micCapInfo = micCapInfo}; - - OHOS::NWeb::VideoCaptureInfoAdapter videoCapInfo = { - .videoFrameWidth = videoFrameWidth, - .videoFrameHeight = videoFrameHeight, - .videoSource = - OHOS::NWeb::VideoSourceTypeAdapter::VIDEO_SOURCE_SURFACE_RGBA - }; - OHOS::NWeb::VideoInfoAdapter videoInfo = {.videoCapInfo = videoCapInfo}; - OHOS::NWeb::ScreenCaptureConfigAdapter config = { - .captureMode = OHOS::NWeb::CaptureModeAdapter::CAPTURE_HOME_SCREEN, - .dataType = OHOS::NWeb::DataTypeAdapter::ORIGINAL_STREAM_DATA_TYPE, - .audioInfo = audioInfo, - .videoInfo = videoInfo - }; + + std::shared_ptr micCapInfo = + std::make_shared(); + micCapInfo->SetAudioSampleRate(kAudioSampleRate); + micCapInfo->SetAudioChannels(kAudioChannels); + micCapInfo->SetAudioSource( + OHOS::NWeb::AudioCaptureSourceTypeAdapter::SOURCE_DEFAULT); + + std::shared_ptr audioInfo = + std::make_shared(); + audioInfo->SetMicCapInfo(micCapInfo); + + std::shared_ptr videoCapInfo = + std::make_shared(); + videoCapInfo->SetVideoFrameWidth(videoFrameWidth); + videoCapInfo->SetVideoFrameHeight(videoFrameHeight); + videoCapInfo->SetVideoSourceType( + OHOS::NWeb::VideoSourceTypeAdapter::VIDEO_SOURCE_SURFACE_RGBA); + + std::shared_ptr videoInfo = + std::make_shared(); + videoInfo->SetVideoCapInfo(videoCapInfo); + + std::shared_ptr config = + std::make_shared(); + config->SetCaptureMode(OHOS::NWeb::CaptureModeAdapter::CAPTURE_HOME_SCREEN); + config->SetDataType(OHOS::NWeb::DataTypeAdapter::ORIGINAL_STREAM_DATA_TYPE); + config->SetAudioInfo(audioInfo); + config->SetVideoInfo(videoInfo); + if (screen_capture_adapter_->Init(config) != 0) { screen_capture_adapter_ = nullptr; LOG(ERROR) << "screen capture init failed"; @@ -280,7 +297,8 @@ void BaseWindowCapturer::HandleBuffer() { pData += frameStride; pSrcData += stride; } - current_frame->mutable_updated_region()->SetRect(DesktopRect::MakeSize(current_frame->size())); + current_frame->mutable_updated_region()->SetRect( + DesktopRect::MakeSize(current_frame->size())); { webrtc::MutexLock lock(¤t_frame_lock_); diff --git a/modules/desktop_capture/ohos/recorder_info_adapter_impl.cc b/modules/desktop_capture/ohos/recorder_info_adapter_impl.cc new file mode 100644 index 00000000..9a6a9c57 --- /dev/null +++ b/modules/desktop_capture/ohos/recorder_info_adapter_impl.cc @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "recorder_info_adapter_impl.h" + +namespace OHOS::NWeb { + +std::string RecorderInfoAdapterImpl::GetUrl() { + return url_; +} + +ContainerFormatTypeAdapter RecorderInfoAdapterImpl::GetFileFormat() { + return file_format_; +} + +void RecorderInfoAdapterImpl::SetUrl(std::string url) { + url_ = url; +} + +void RecorderInfoAdapterImpl::SetFileFormat(ContainerFormatTypeAdapter format) { + file_format_ = format; +} + +} // namespace OHOS::NWeb diff --git a/modules/desktop_capture/ohos/recorder_info_adapter_impl.h b/modules/desktop_capture/ohos/recorder_info_adapter_impl.h new file mode 100644 index 00000000..6a07f104 --- /dev/null +++ b/modules/desktop_capture/ohos/recorder_info_adapter_impl.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef RECORDER_INFO_ADAPTER_IMPL_H +#define RECORDER_INFO_ADAPTER_IMPL_H + +#include "screen_capture_adapter.h" + +namespace OHOS::NWeb { + +class RecorderInfoAdapterImpl : public RecorderInfoAdapter { + public: + RecorderInfoAdapterImpl() = default; + + std::string GetUrl() override; + + ContainerFormatTypeAdapter GetFileFormat() override; + + void SetUrl(std::string url); + + void SetFileFormat(ContainerFormatTypeAdapter format); + + private: + /* Recorder file url */ + std::string url_ = ""; + /* Recorder file format */ + ContainerFormatTypeAdapter file_format_ = + ContainerFormatTypeAdapter::CFT_MPEG_4A_TYPE; +}; + +} // namespace OHOS::NWeb + +#endif // RECORDER_INFO_ADAPTER_IMPL_H diff --git a/modules/desktop_capture/ohos/screen_capture_config_adapter_impl.cc b/modules/desktop_capture/ohos/screen_capture_config_adapter_impl.cc new file mode 100644 index 00000000..f1d1bee7 --- /dev/null +++ b/modules/desktop_capture/ohos/screen_capture_config_adapter_impl.cc @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "screen_capture_config_adapter_impl.h" + +namespace OHOS::NWeb { + +CaptureModeAdapter ScreenCaptureConfigAdapterImpl::GetCaptureMode() { + return capture_mode_; +} + +DataTypeAdapter ScreenCaptureConfigAdapterImpl::GetDataType() { + return data_type_; +} + +std::shared_ptr +ScreenCaptureConfigAdapterImpl::GetAudioInfo() { + return audio_info_; +} + +std::shared_ptr +ScreenCaptureConfigAdapterImpl::GetVideoInfo() { + return video_info_; +} + +std::shared_ptr +ScreenCaptureConfigAdapterImpl::GetRecorderInfo() { + return recorder_info_; +} + +void ScreenCaptureConfigAdapterImpl::SetCaptureMode(CaptureModeAdapter mode) { + capture_mode_ = mode; +} + +void ScreenCaptureConfigAdapterImpl::SetDataType(DataTypeAdapter type) { + data_type_ = type; +} + +void ScreenCaptureConfigAdapterImpl::SetAudioInfo( + std::shared_ptr info) { + audio_info_ = info; +} + +void ScreenCaptureConfigAdapterImpl::SetVideoInfo( + std::shared_ptr info) { + video_info_ = info; +} + +void ScreenCaptureConfigAdapterImpl::SetRecorderInfo( + std::shared_ptr info) { + recorder_info_ = info; +} + +} // namespace OHOS::NWeb diff --git a/modules/desktop_capture/ohos/screen_capture_config_adapter_impl.h b/modules/desktop_capture/ohos/screen_capture_config_adapter_impl.h new file mode 100644 index 00000000..cbed7e3c --- /dev/null +++ b/modules/desktop_capture/ohos/screen_capture_config_adapter_impl.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SCREEN_CAPTURE_CONFIG_ADAPTER_IMPL_H +#define SCREEN_CAPTURE_CONFIG_ADAPTER_IMPL_H + +#include "screen_capture_adapter.h" + +namespace OHOS::NWeb { + +class ScreenCaptureConfigAdapterImpl : public ScreenCaptureConfigAdapter { + public: + ScreenCaptureConfigAdapterImpl() = default; + + CaptureModeAdapter GetCaptureMode() override; + + DataTypeAdapter GetDataType() override; + + std::shared_ptr GetAudioInfo() override; + + std::shared_ptr GetVideoInfo() override; + + std::shared_ptr GetRecorderInfo() override; + + void SetCaptureMode(CaptureModeAdapter mode); + + void SetDataType(DataTypeAdapter type); + + void SetAudioInfo(std::shared_ptr info); + + void SetVideoInfo(std::shared_ptr info); + + void SetRecorderInfo(std::shared_ptr info); + + private: + CaptureModeAdapter capture_mode_ = CaptureModeAdapter::CAPTURE_INVAILD; + DataTypeAdapter data_type_ = DataTypeAdapter::INVAILD_DATA_TYPE; + std::shared_ptr audio_info_ = nullptr; + std::shared_ptr video_info_ = nullptr; + /* should be set, while dataType = CAPTURE_FILE */ + std::shared_ptr recorder_info_ = nullptr; +}; + +} // namespace OHOS::NWeb + +#endif // SCREEN_CAPTURE_CONFIG_ADAPTER_IMPL_H diff --git a/modules/desktop_capture/ohos/video_capture_info_adapter_impl.cc b/modules/desktop_capture/ohos/video_capture_info_adapter_impl.cc new file mode 100644 index 00000000..a3334fbb --- /dev/null +++ b/modules/desktop_capture/ohos/video_capture_info_adapter_impl.cc @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "video_capture_info_adapter_impl.h" + +namespace OHOS::NWeb { + +uint64_t VideoCaptureInfoAdapterImpl::GetDisplayId() { + return display_id_; +} + +std::list VideoCaptureInfoAdapterImpl::GetTaskIDs() { + return task_ids_; +} + +int32_t VideoCaptureInfoAdapterImpl::GetVideoFrameWidth() { + return video_frame_width_; +} + +int32_t VideoCaptureInfoAdapterImpl::GetVideoFrameHeight() { + return video_frame_height_; +} + +VideoSourceTypeAdapter VideoCaptureInfoAdapterImpl::GetVideoSourceType() { + return video_source_; +} + +void VideoCaptureInfoAdapterImpl::SetDisplayId(uint64_t id) { + display_id_ = id; +} + +void VideoCaptureInfoAdapterImpl::SetTaskIDs(std::list ids) { + task_ids_ = ids; +} + +void VideoCaptureInfoAdapterImpl::SetVideoFrameWidth(int32_t width) { + video_frame_width_ = width; +} + +void VideoCaptureInfoAdapterImpl::SetVideoFrameHeight(int32_t height) { + video_frame_height_ = height; +} + +void VideoCaptureInfoAdapterImpl::SetVideoSourceType( + VideoSourceTypeAdapter type) { + video_source_ = type; +} +} // namespace OHOS::NWeb diff --git a/modules/desktop_capture/ohos/video_capture_info_adapter_impl.h b/modules/desktop_capture/ohos/video_capture_info_adapter_impl.h new file mode 100644 index 00000000..e25bbf02 --- /dev/null +++ b/modules/desktop_capture/ohos/video_capture_info_adapter_impl.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef VIDEO_CAPTURE_INFO_ADAPTER_IMPL_H +#define VIDEO_CAPTURE_INFO_ADAPTER_IMPL_H + +#include "screen_capture_adapter.h" + +namespace OHOS::NWeb { + +class VideoCaptureInfoAdapterImpl : public VideoCaptureInfoAdapter { + public: + VideoCaptureInfoAdapterImpl() = default; + + uint64_t GetDisplayId() override; + + std::list GetTaskIDs() override; + + int32_t GetVideoFrameWidth() override; + + int32_t GetVideoFrameHeight() override; + + VideoSourceTypeAdapter GetVideoSourceType() override; + + void SetDisplayId(uint64_t id); + + void SetTaskIDs(std::list ids); + + void SetVideoFrameWidth(int32_t width); + + void SetVideoFrameHeight(int32_t height); + + void SetVideoSourceType(VideoSourceTypeAdapter type); + + private: + /* Display id, should be set while captureMode = CAPTURE_SPECIFIED_SCREEN */ + uint64_t display_id_ = 0; + /* The ids of mission, should be set while captureMode = + * CAPTURE_SPECIFIED_WINDOW */ + std::list task_ids_; + /* Video frame width of avscreeencapture */ + int32_t video_frame_width_ = 0; + /* Video frame height of avscreeencapture */ + int32_t video_frame_height_ = 0; + /* Video source type of avscreeencapture */ + VideoSourceTypeAdapter video_source_ = + VideoSourceTypeAdapter::VIDEO_SOURCE_SURFACE_RGBA; +}; + +} // namespace OHOS::NWeb + +#endif // VIDEO_CAPTURE_INFO_ADAPTER_IMPL_H diff --git a/modules/desktop_capture/ohos/video_enc_info_adapter_impl.cc b/modules/desktop_capture/ohos/video_enc_info_adapter_impl.cc new file mode 100644 index 00000000..54337679 --- /dev/null +++ b/modules/desktop_capture/ohos/video_enc_info_adapter_impl.cc @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "video_enc_info_adapter_impl.h" + +namespace OHOS::NWeb { + +VideoCodecFormatAdapter VideoEncInfoAdapterImpl::GetVideoCodecFormat() { + return codec_; +} + +int32_t VideoEncInfoAdapterImpl::GetVideoBitrate() { + return bitrate_; +} + +int32_t VideoEncInfoAdapterImpl::GetVideoFrameRate() { + return frame_rate_; +} + +void VideoEncInfoAdapterImpl::SetVideoCodecFormat( + VideoCodecFormatAdapter format) { + codec_ = format; +} + +void VideoEncInfoAdapterImpl::SetVideoBitrate(int32_t bitrate) { + bitrate_ = bitrate; +} + +void VideoEncInfoAdapterImpl::SetVideoFrameRate(int32_t frameRate) { + frame_rate_ = frameRate; +} +} // namespace OHOS::NWeb diff --git a/modules/desktop_capture/ohos/video_enc_info_adapter_impl.h b/modules/desktop_capture/ohos/video_enc_info_adapter_impl.h new file mode 100644 index 00000000..6f3a52e6 --- /dev/null +++ b/modules/desktop_capture/ohos/video_enc_info_adapter_impl.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef VIDEO_ENC_INFO_ADAPTER_IMPL_H +#define VIDEO_ENC_INFO_ADAPTER_IMPL_H + +#include "screen_capture_adapter.h" + +namespace OHOS::NWeb { + +class VideoEncInfoAdapterImpl : public VideoEncInfoAdapter { + public: + VideoEncInfoAdapterImpl() = default; + + VideoCodecFormatAdapter GetVideoCodecFormat() override; + + int32_t GetVideoBitrate() override; + + int32_t GetVideoFrameRate() override; + + void SetVideoCodecFormat(VideoCodecFormatAdapter format); + + void SetVideoBitrate(int32_t bitrate); + + void SetVideoFrameRate(int32_t frameRate); + + private: + /* Video encoder format */ + VideoCodecFormatAdapter codec_ = VideoCodecFormatAdapter::VIDEO_DEFAULT; + /* Video encoder bitrate */ + int32_t bitrate_ = 0; + /* Video encoder frame rate */ + int32_t frame_rate_ = 0; +}; + +} // namespace OHOS::NWeb + +#endif // VIDEO_ENC_INFO_ADAPTER_IMPL_H diff --git a/modules/desktop_capture/ohos/video_info_adapter_impl.cc b/modules/desktop_capture/ohos/video_info_adapter_impl.cc new file mode 100644 index 00000000..97fc4679 --- /dev/null +++ b/modules/desktop_capture/ohos/video_info_adapter_impl.cc @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "video_info_adapter_impl.h" + +namespace OHOS::NWeb { + +std::shared_ptr +VideoInfoAdapterImpl::GetVideoCapInfo() { + return cap_info_; +} + +std::shared_ptr VideoInfoAdapterImpl::GetVideoEncInfo() { + return enc_info_; +} + +void VideoInfoAdapterImpl::SetVideoCapInfo( + std::shared_ptr info) { + cap_info_ = info; +} + +void VideoInfoAdapterImpl::SetVideoEncInfo( + std::shared_ptr info) { + enc_info_ = info; +} +} // namespace OHOS::NWeb diff --git a/modules/desktop_capture/ohos/video_info_adapter_impl.h b/modules/desktop_capture/ohos/video_info_adapter_impl.h new file mode 100644 index 00000000..2f1aa46c --- /dev/null +++ b/modules/desktop_capture/ohos/video_info_adapter_impl.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef VIDEO_INFO_ADAPTER_IMPL_H +#define VIDEO_INFO_ADAPTER_IMPL_H + +#include "screen_capture_adapter.h" + +namespace OHOS::NWeb { + +class VideoInfoAdapterImpl : public VideoInfoAdapter { + public: + VideoInfoAdapterImpl() = default; + + std::shared_ptr GetVideoCapInfo() override; + + std::shared_ptr GetVideoEncInfo() override; + + void SetVideoCapInfo(std::shared_ptr info); + + void SetVideoEncInfo(std::shared_ptr info); + + private: + /* Video capture info */ + std::shared_ptr cap_info_ = nullptr; + /* Video encoder info */ + std::shared_ptr enc_info_ = nullptr; +}; + +} // namespace OHOS::NWeb + +#endif // VIDEO_INFO_ADAPTER_IMPL_H -- Gitee