Agora Java API Reference for Android
NGIAgoraExtensionScreenSource.h
1 //
2 // Agora SDK
3 //
4 // Copyright (c) 2021 Agora.io. All rights reserved.
5 //
6 
7 #pragma once // NOLINT(build/header_guard)
8 
9 #include "AgoraBase.h"
10 #include "IAgoraLog.h"
11 #include "AgoraRefPtr.h"
12 #include "NGIAgoraVideoFrame.h"
13 #include "AgoraMediaBase.h"
14 
15 namespace agora {
16 namespace rtc {
17 
19  int capture_type;
20  uint32_t captured_frame_width;
21  uint32_t captured_frame_height;
22  uint32_t total_captured_frames;
23  uint64_t per_frame_cap_time_ms;
24  uint64_t per_capture_cpu_cycles;
25  bool capture_mouse_cursor;
26 
28  : capture_type(-1), captured_frame_width(0), captured_frame_height(0),
29  total_captured_frames(0), per_frame_cap_time_ms(0),
30  per_capture_cpu_cycles(0), capture_mouse_cursor(true) {}
31 };
32 
34  public:
35  class Control : public RefCountInterface {
36  public:
37  virtual int postEvent(const char* key, const char* value) = 0;
38  virtual void printLog(commons::LOG_LEVEL level, const char* format, ...) = 0;
39  virtual int pushAudioFrame(const media::IAudioFrameObserver::AudioFrame& captured_frame) = 0;
40  virtual bool timeToPushVideo() = 0;
41  virtual int pushVideoFrame(const agora::agora_refptr<IVideoFrame>& captured_frame) = 0;
42  virtual agora::agora_refptr<IVideoFrameMemoryPool> getMemoryPool() = 0;
43  };
44 
46  uint32_t volume;
47  int sample_rate_hz;
48  int num_channels;
49  AudioCaptureConfig() : volume(0), sample_rate_hz(0), num_channels(0) {}
50  };
51 
52 #if defined (__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE)
53  struct VideoCaptureConfig {
54  agora::rtc::VideoDimensions dimensions;
56  : dimensions(640, 360) {}
57  };
58 #else
60  enum CaptureType {
61  CaptureWindow,
62  CaptureScreen,
63  };
64  CaptureType type;
65  Rectangle screen_rect;
66  Rectangle region_offset;
67  uint32_t display_id;
68  view_t window_id;
69 
71  : type(CaptureScreen), screen_rect(), region_offset(), display_id(0), window_id(NULL) { }
72  };
73 #endif
74  enum CaptureMode {
75  kPull, // SDK needs to poll the captured frame actively
76  kPush // Capture source pushes the captured frame to sdk
77  };
78  #if defined(_WIN32)
79  enum VideoContentSubType {
80  UNSPECIFIED = 0, // if camera, trade as camera; if share trade as document
81  SHARE_DOCUMENT = 1,
82  SHARE_GAMING = 2,
83  SHARE_VIDEO = 3,
84  SHARE_RDC = 4, // remote desktop control
85  SHARE_HFHD = 5, // high frame-rate high definition screen share
86  MAX = 16,
87 };
88 #endif
89 
90 
91  virtual ~IScreenCaptureSource() {}
92 
93  virtual int initializeCapture(const agora_refptr<Control>& control) = 0;
94 
95  // Start video capture interface for desktop capturing
96  virtual int startVideoCapture(const VideoCaptureConfig& config) = 0;
97  virtual int stopVideoCapture() = 0;
98 
99  virtual CaptureMode getVideoCaptureMode() = 0;
100 
101  // Implementation of the following interfaces are not mandatory
102  virtual int startAudioCapture(const AudioCaptureConfig& config) {
103  return -ERR_NOT_SUPPORTED;
104  }
105  virtual int stopAudioCapture() {
106  return -ERR_NOT_SUPPORTED;
107  }
108  virtual int setAudioVolume(uint32_t volume) {
109  return -ERR_NOT_SUPPORTED;
110  }
111  virtual int setFrameRate(int fps) {
112  return -ERR_NOT_SUPPORTED;
113  }
114  virtual int setScreenCaptureDimensions(const agora::rtc::VideoDimensions& dimensions) {
115  return -ERR_NOT_SUPPORTED;
116  }
117  virtual int updateCaptureRegion(const agora::rtc::Rectangle& captureRegion) {
118  return -ERR_NOT_SUPPORTED;
119  }
120  virtual int setExcludeWindowList(void* const * handles, int count) {
121  return -ERR_NOT_SUPPORTED;
122  }
123  virtual int captureMouseCursor(bool capture) {
124  return -ERR_NOT_SUPPORTED;
125  }
126  virtual int capture(agora::agora_refptr<IVideoFrame>& frame) {
127  return -ERR_NOT_SUPPORTED;
128  }
129  virtual int getProfilingStats(ScreenCaptureProfilingStatistics& stats) {
130  return -ERR_NOT_SUPPORTED;
131  }
132  virtual int getScreenDimensions(int& width, int& height) {
133  return ERR_NOT_SUPPORTED;
134  }
135  virtual int setProperty(const char* key, const char* json_value) {
136  return -ERR_NOT_SUPPORTED;
137  }
138  virtual int setCustomContext(const char* key, const void* context) {
139  return -ERR_NOT_SUPPORTED;
140  }
141  virtual int getProperty(const char* key, char* json_value, int& length) {
142  return -ERR_NOT_SUPPORTED;
143  }
144  virtual void* getCustomContext(const char* key) {
145  return NULL;
146  }
147  virtual void* getScreenCaptureSources(int thumb_cx, int thumb_cy, int icon_cx, int icon_cy,
148  bool include_screen) {
149  return NULL;
150  }
151 #if defined(_WIN32)
152  virtual int SetContentType(VideoContentSubType type) {
153  return -ERR_NOT_SUPPORTED;
154  }
155 #endif
156 };
157 
158 } // namespace rtc
159 } // namespace agora
agora::rtc::ScreenCaptureProfilingStatistics
Definition: NGIAgoraExtensionScreenSource.h:18
agora::agora_refptr
Definition: AgoraRefPtr.h:44
agora::rtc::Rectangle
Definition: AgoraBase.h:1855
agora::media::IAudioFrameObserverBase::AudioFrame
Definition: AgoraMediaBase.h:807
agora::rtc::IScreenCaptureSource::AudioCaptureConfig
Definition: NGIAgoraExtensionScreenSource.h:45
agora::rtc::IScreenCaptureSource::Control
Definition: NGIAgoraExtensionScreenSource.h:35
agora::rtc::IScreenCaptureSource
Definition: NGIAgoraExtensionScreenSource.h:33
agora::RefCountInterface
Definition: AgoraRefPtr.h:31
agora::rtc::VideoDimensions
Definition: AgoraBase.h:1073
agora::rtc::IScreenCaptureSource::VideoCaptureConfig
Definition: NGIAgoraExtensionScreenSource.h:59