diff --git a/webrtc/modules/desktop_capture/desktop_capture_types.h b/webrtc/modules/desktop_capture/desktop_capture_types.h index 9a6162a766..8b8c116af2 100644 --- a/webrtc/modules/desktop_capture/desktop_capture_types.h +++ b/webrtc/modules/desktop_capture/desktop_capture_types.h @@ -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(a)) | (static_cast(b) << 8) | \ + (static_cast(c) << 16) | (static_cast(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_ diff --git a/webrtc/modules/desktop_capture/desktop_frame.cc b/webrtc/modules/desktop_capture/desktop_frame.cc index dfc0928b66..12e4ed8a09 100644 --- a/webrtc/modules/desktop_capture/desktop_frame.cc +++ b/webrtc/modules/desktop_capture/desktop_frame.cc @@ -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() {} diff --git a/webrtc/modules/desktop_capture/desktop_frame.h b/webrtc/modules/desktop_capture/desktop_frame.h index d491135029..c0eaf03aa6 100644 --- a/webrtc/modules/desktop_capture/desktop_frame.h +++ b/webrtc/modules/desktop_capture/desktop_frame.h @@ -14,6 +14,7 @@ #include #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); }; diff --git a/webrtc/modules/desktop_capture/win/screen_capturer_win_directx.cc b/webrtc/modules/desktop_capture/win/screen_capturer_win_directx.cc index f6222d0d1a..90bdeb6124 100644 --- a/webrtc/modules/desktop_capture/win/screen_capturer_win_directx.cc +++ b/webrtc/modules/desktop_capture/win/screen_capturer_win_directx.cc @@ -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)); } diff --git a/webrtc/modules/desktop_capture/win/screen_capturer_win_gdi.cc b/webrtc/modules/desktop_capture/win/screen_capturer_win_gdi.cc index 87bc195ce4..591adca26f 100644 --- a/webrtc/modules/desktop_capture/win/screen_capturer_win_gdi.cc +++ b/webrtc/modules/desktop_capture/win/screen_capturer_win_gdi.cc @@ -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)); }