blob: 236ae48011eeda0b6a0aa1d22066ada1ac669fcf [file] [log] [blame]
zijiehecf5753d2017-04-20 12:06:04 -07001/*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_DXGI_FRAME_H_
12#define WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_DXGI_FRAME_H_
13
14#include <memory>
15#include <vector>
16
17#include "webrtc/modules/desktop_capture/desktop_capturer.h"
18#include "webrtc/modules/desktop_capture/desktop_capture_types.h"
19#include "webrtc/modules/desktop_capture/desktop_geometry.h"
Zijie He7e1c24c2017-07-27 18:06:12 -070020#include "webrtc/modules/desktop_capture/resolution_tracker.h"
zijiehecf5753d2017-04-20 12:06:04 -070021#include "webrtc/modules/desktop_capture/shared_desktop_frame.h"
22#include "webrtc/modules/desktop_capture/shared_memory.h"
23#include "webrtc/modules/desktop_capture/win/dxgi_context.h"
24
25namespace webrtc {
26
27class DxgiDuplicatorController;
28
29// A pair of a SharedDesktopFrame and a DxgiDuplicatorController::Context for
30// the client of DxgiDuplicatorController.
31class DxgiFrame final {
32 public:
33 using Context = DxgiFrameContext;
34
35 // DxgiFrame does not take ownership of |factory|, consumers should ensure it
36 // outlives this instance. nullptr is acceptable.
37 explicit DxgiFrame(SharedMemoryFactory* factory);
38 ~DxgiFrame();
39
40 // Should not be called if Prepare() is not executed or returns false.
41 SharedDesktopFrame* frame() const;
42
43 private:
44 // Allows DxgiDuplicatorController to access Prepare() and context() function
45 // as well as Context class.
46 friend class DxgiDuplicatorController;
47
48 // Prepares current instance with desktop size and source id.
49 bool Prepare(DesktopSize size, DesktopCapturer::SourceId source_id);
50
51 // Should not be called if Prepare() is not executed or returns false.
52 Context* context();
53
54 SharedMemoryFactory* const factory_;
Zijie He7e1c24c2017-07-27 18:06:12 -070055 ResolutionTracker resolution_tracker_;
zijiehecf5753d2017-04-20 12:06:04 -070056 DesktopCapturer::SourceId source_id_ = kFullDesktopScreenId;
57 std::unique_ptr<SharedDesktopFrame> frame_;
58 Context context_;
59};
60
61} // namespace webrtc
62
63#endif // WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_DXGI_FRAME_H_