1 /* GStreamer 2 * Copyright (C) 2019 OKADA Jun-ichi <okada@abt.jp> 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public 15 * License along with this library; if not, write to the 16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef __DXGICAP_H__ 21 #define __DXGICAP_H__ 22 23 #define COBJMACROS 24 #include <d3d11.h> 25 #include <dxgi.h> 26 #include <dxgi1_2.h> 27 #undef COBJMACROS 28 29 #include <gst/gst.h> 30 #include <gst/base/gstpushsrc.h> 31 #include <gst/video/video.h> 32 33 #define RECT_WIDTH(r) (r.right - r.left) 34 #define RECT_HEIGHT(r) (r.bottom - r.top) 35 36 #define HR_FAILED_AND(hr,func,and) \ 37 G_STMT_START { \ 38 if (FAILED (hr)) { \ 39 gchar *msg = get_hresult_to_string (hr); \ 40 GST_ERROR_OBJECT (src, #func " failed (%x): %s", (guint) hr, msg); \ 41 g_free (msg); \ 42 and; \ 43 } \ 44 } G_STMT_END 45 46 #define HR_FAILED_RET(hr,func,ret) HR_FAILED_AND(hr,func,return ret) 47 48 #define HR_FAILED_GOTO(hr,func,where) HR_FAILED_AND(hr,func,goto where) 49 50 #define HR_FAILED_INFO(hr, func) \ 51 G_STMT_START { \ 52 if (FAILED (hr)) { \ 53 gchar *msg = get_hresult_to_string (hr); \ 54 GST_INFO_OBJECT (src, #func " failed (%x): %s", (guint) hr, msg); \ 55 g_free (msg); \ 56 } \ 57 } G_STMT_END 58 59 #define GST_DXGICAP_FLOW_RESOLUTION_CHANGE GST_FLOW_CUSTOM_SUCCESS_1 60 61 typedef struct _GstDXGIScreenCapSrc GstDXGIScreenCapSrc; 62 63 typedef struct _DxgiCapture DxgiCapture; 64 65 gboolean gst_dxgicap_shader_init (void); 66 67 DxgiCapture *dxgicap_new (HMONITOR monitor, GstDXGIScreenCapSrc * src); 68 void dxgicap_destory (DxgiCapture * _this); 69 70 gboolean dxgicap_start (DxgiCapture * _this); 71 void dxgicap_stop (DxgiCapture * _this); 72 73 GstFlowReturn dxgicap_acquire_next_frame (DxgiCapture * _this, gboolean show_cursor, 74 guint timeout); 75 gboolean dxgicap_copy_buffer (DxgiCapture * _this, gboolean show_cursor, 76 LPRECT src_rect, GstVideoInfo * video_info, GstBuffer * buf); 77 78 HMONITOR get_hmonitor_by_device_name (const gchar * device_name); 79 HMONITOR get_hmonitor_primary (void); 80 HMONITOR get_hmonitor_by_index (int index); 81 82 gboolean get_monitor_physical_size (HMONITOR hmonitor, LPRECT rect); 83 84 gchar *get_hresult_to_string (HRESULT hr); 85 86 #endif /* __DXGICAP_H__ */ 87