Add DesktopCapturerId and attach it to DesktopFrame
This change adds a DesktopCapturerId namespace, and attaches an int to each DesktopFrame. ScreenCapturerWinGdi and ScreenCapturerWinDirectx now actively set this field to differentiate themselves. BUG=679523, 650926 Review-Url: https://codereview.webrtc.org/2759493002 Cr-Commit-Position: refs/heads/master@{#17329}
This commit is contained in:
parent
14325edfe4
commit
41e3d9ff3b
@ -29,6 +29,7 @@ rtc_static_library("primitives") {
|
||||
deps = [
|
||||
"../..:webrtc_common",
|
||||
"../../base:rtc_base", # TODO(kjellander): Cleanup in bugs.webrtc.org/3806.
|
||||
"../../media:rtc_media_base",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
include_rules = [
|
||||
"+webrtc/base",
|
||||
"+webrtc/media",
|
||||
"+webrtc/system_wrappers",
|
||||
"+third_party/libyuv",
|
||||
]
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "webrtc/media/base/videocommon.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -36,6 +37,14 @@ const ScreenId kFullDesktopScreenId = -1;
|
||||
|
||||
const ScreenId kInvalidScreenId = -2;
|
||||
|
||||
// An integer to attach to each DesktopFrame to differentiate the generator of
|
||||
// the frame.
|
||||
namespace DesktopCapturerId {
|
||||
constexpr uint32_t kUnknown = 0;
|
||||
constexpr uint32_t kScreenCapturerWinGdi = FOURCC('G', 'D', 'I', ' ');
|
||||
constexpr uint32_t kScreenCapturerWinDirectx = FOURCC('D', 'X', 'G', 'I');
|
||||
} // namespace DesktopCapturerId
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURE_TYPES_H_
|
||||
|
||||
@ -26,8 +26,8 @@ DesktopFrame::DesktopFrame(DesktopSize size,
|
||||
shared_memory_(shared_memory),
|
||||
size_(size),
|
||||
stride_(stride),
|
||||
capture_time_ms_(0) {
|
||||
}
|
||||
capture_time_ms_(0),
|
||||
capturer_id_(DesktopCapturerId::kUnknown) {}
|
||||
|
||||
DesktopFrame::~DesktopFrame() {}
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capture_types.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_geometry.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_region.h"
|
||||
#include "webrtc/modules/desktop_capture/shared_memory.h"
|
||||
@ -68,6 +69,14 @@ class DesktopFrame {
|
||||
// A helper to return the data pointer of a frame at the specified position.
|
||||
uint8_t* GetFrameDataAtPos(const DesktopVector& pos) const;
|
||||
|
||||
// The DesktopCapturer implementation which generates current DesktopFrame.
|
||||
// Not all DesktopCapturer implementations set this field; it's set to
|
||||
// kUnknown by default.
|
||||
uint32_t capturer_id() const { return capturer_id_; }
|
||||
void set_capturer_id(uint32_t capturer_id) {
|
||||
capturer_id_ = capturer_id;
|
||||
}
|
||||
|
||||
protected:
|
||||
DesktopFrame(DesktopSize size,
|
||||
int stride,
|
||||
@ -87,6 +96,7 @@ class DesktopFrame {
|
||||
DesktopRegion updated_region_;
|
||||
DesktopVector dpi_;
|
||||
int64_t capture_time_ms_;
|
||||
uint32_t capturer_id_;
|
||||
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(DesktopFrame);
|
||||
};
|
||||
|
||||
@ -137,6 +137,7 @@ void ScreenCapturerWinDirectx::CaptureFrame() {
|
||||
result->set_capture_time_ms(
|
||||
(rtc::TimeNanos() - capture_start_time_nanos) /
|
||||
rtc::kNumNanosecsPerMillisec);
|
||||
result->set_capturer_id(DesktopCapturerId::kScreenCapturerWinDirectx);
|
||||
callback_->OnCaptureResult(Result::SUCCESS, std::move(result));
|
||||
}
|
||||
|
||||
|
||||
@ -94,6 +94,7 @@ void ScreenCapturerWinGdi::CaptureFrame() {
|
||||
frame->set_capture_time_ms(
|
||||
(rtc::TimeNanos() - capture_start_time_nanos) /
|
||||
rtc::kNumNanosecsPerMillisec);
|
||||
frame->set_capturer_id(DesktopCapturerId::kScreenCapturerWinGdi);
|
||||
callback_->OnCaptureResult(Result::SUCCESS, std::move(frame));
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user