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-Original-Commit-Position: refs/heads/master@{#17329}
Committed: 41e3d9ff3b
Review-Url: https://codereview.webrtc.org/2759493002
Cr-Commit-Position: refs/heads/master@{#17347}
This commit is contained in:
parent
ce302b82c9
commit
88ac827877
@ -36,6 +36,34 @@ const ScreenId kFullDesktopScreenId = -1;
|
||||
|
||||
const ScreenId kInvalidScreenId = -2;
|
||||
|
||||
// Depends on webrtc/media:rtc_media_base will trigger a build break in
|
||||
// Chromium (Refer to https://codereview.chromium.org/2759493002/). The root
|
||||
// cause is still unclear. Before the root cause has been found, copy-paste the
|
||||
// definition of the FOURCC() macro here is a simple choice.
|
||||
|
||||
/**** Copy from webrtc/media/base/videocommon.h ****/
|
||||
// Convert four characters to a FourCC code.
|
||||
// Needs to be a macro otherwise the OS X compiler complains when the kFormat*
|
||||
// constants are used in a switch.
|
||||
#define FOURCC(a, b, c, d) \
|
||||
((static_cast<uint32_t>(a)) | (static_cast<uint32_t>(b) << 8) | \
|
||||
(static_cast<uint32_t>(c) << 16) | (static_cast<uint32_t>(d) << 24))
|
||||
// Some pages discussing FourCC codes:
|
||||
// http://www.fourcc.org/yuv.php
|
||||
// http://v4l2spec.bytesex.org/spec/book1.htm
|
||||
// http://developer.apple.com/quicktime/icefloe/dispatch020.html
|
||||
// http://msdn.microsoft.com/library/windows/desktop/dd206750.aspx#nv12
|
||||
// http://people.xiph.org/~xiphmont/containers/nut/nut4cc.txt
|
||||
/**** End copy from webrtc/media/base/videocommon.h ****/
|
||||
|
||||
// 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