![]() |
UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
|
#include <cassert>#include <cstdio>#include <iostream>#include <string>#include <tchar.h>#include <dshow.h>#include <dvdmedia.h>#include <qedit.h>#include <oleauto.h>#include <windows.h>#include "debug.h"#include "lib_common.h"#include "tv.h"#include "utils/color_out.h"#include "utils/macros.h"#include "utils/string.h"#include "video.h"#include "video_capture.h"
Go to the source code of this file.
Classes | |
| class | SampleGrabberCallback |
| struct | vidcap_dshow_state |
Macros | |
| #define | DEFAULT_DEVNUM 1 |
| #define | DEFAULT_FPS 15 |
| #define | DEFAULT_VIDEO_HEIGHT 480 |
| #define | DEFAULT_VIDEO_WIDTH 640 |
| #define | GUID_FROM_FOURCC(fourcc) |
| #define | HANDLE_ERR(msg, ...) |
| #define | HANDLE_ERR(msg, ...) |
| #define | HANDLE_ERR(msg, ...) |
| #define | HANDLE_ERR(msg, ...) |
| #define | HANDLE_ERR_ACTION(res, action, msg, ...) |
| #define | MAX_STRING_LEN 1000 |
| #define | MAX_YUV_CLAMP 535 |
| #define | MIN_YUV_CLAMP -276 |
| #define | MOD_NAME "[dshow] " |
Typedefs | |
| typedef void(* | convert_t) (int width, int height, const unsigned char *in, unsigned char *out) |
Functions | |
| static void | abgr_flip_and_swap (int width, int height, const unsigned char *in, unsigned char *out) |
| convert from ABGR and bottom-to-top | |
| static void | bgr_flip_lines (int width, int height, const unsigned char *in, unsigned char *out) |
| static bool | cleanup (struct vidcap_dshow_state *s) |
| static bool | common_init (struct vidcap_dshow_state *s) |
| static HRESULT | ConnectFilters (IGraphBuilder *g, IBaseFilter *fromFilter, IBaseFilter *toFilter) |
| static HRESULT | ConnectFilters (IGraphBuilder *g, IPin *fromPin, IBaseFilter *toFilter) |
| static void | convert_yuv_rgb (BYTE y, BYTE u, BYTE v, BYTE *dst) |
| static void | convert_yuyv_rgb (BYTE *src, BYTE *dst, int input_len) |
| static void | DeleteMediaType (AM_MEDIA_TYPE *mediaType) |
| static void | ErrorDescription (HRESULT hr) |
| static HRESULT | FindUnconnectedPin (IBaseFilter *filter, PIN_DIRECTION direction, IPin **pin) |
| static void | FreeMediaType (AM_MEDIA_TYPE &mt) |
| static convert_t | get_conversion (const GUID *pSubtype) |
| static string | get_friendly_name (IMoniker *moniker, int idx=-1) |
| static codec_t | get_ug_codec (const GUID *pSubtype) |
| static codec_t | get_ug_from_subtype_name (const char *subtype_name) |
| static HRESULT | GetPinCategory (IPin *pPin, GUID *pPinCategory) |
| static const CHAR * | GetSubtypeName (const GUID *pSubtype) |
| static const CHAR * | GetSubtypeNameA (const GUID *pSubtype) |
| static HRESULT | GraphPause (IMediaControl *mc) |
| static HRESULT | GraphRun (IMediaControl *mc) |
| static int | LocateSubtype (const GUID *pSubtype) |
| static void | nv12_to_uyvy (int width, int height, const unsigned char *in, unsigned char *out) |
| static HRESULT | PinHasDirection (IPin *pin, PIN_DIRECTION direction, bool *result) |
| static HRESULT | PinIsConnected (IPin *pin, bool *result) |
| static bool | process_args (struct vidcap_dshow_state *s, char *init_fmt) |
| REGISTER_MODULE (dshow, &vidcap_dshow_info, LIBRARY_CLASS_VIDEO_CAPTURE, VIDEO_CAPTURE_ABI_VERSION) | |
| static void | show_help (struct vidcap_dshow_state *s, const char *help_str) |
| static void | vidcap_dshow_done (void *state) |
| static struct video_desc | vidcap_dshow_get_video_desc (AM_MEDIA_TYPE *mediaType) |
| static struct video_frame * | vidcap_dshow_grab (void *state, struct audio_frame **audio) |
| static int | vidcap_dshow_init (struct vidcap_params *params, void **state) |
| static void | vidcap_dshow_probe (device_info **available_cards, int *count, void(**deleter)(void *)) |
| static void | vidcap_dshow_probe_internal (device_info **available_cards, int *count, void(**deleter)(void *), bool include_unsupported) |
| static void | vidcap_dshow_should_exit (void *state) |
Variables | ||
| struct { | ||
| convert_t convert | ||
| const CHAR * pName | ||
| const GUID * pSubtype | ||
| codec_t ug_codec | ||
| } | BitCountMap [] | |
| EXTERN_C const CLSID | CLSID_NullRenderer | |
| EXTERN_C const CLSID | CLSID_SampleGrabber | |
| static const GUID | GUID_AV01 = GUID_FROM_FOURCC(to_fourcc('A', 'V', '0', '1')) | |
| static const GUID | GUID_H264 = GUID_FROM_FOURCC(to_fourcc('H', '2', '6', '4')) | |
| static const GUID | GUID_HDYC = GUID_FROM_FOURCC(0x43594448) | |
| static const GUID | GUID_HEVC = GUID_FROM_FOURCC(to_fourcc('H', 'E', 'V', 'C')) | |
| static const GUID | GUID_I420 = GUID_FROM_FOURCC(0x30323449) | |
| static const GUID | GUID_R210 = GUID_FROM_FOURCC(0x30313272) | |
| static const GUID | GUID_V210 = GUID_FROM_FOURCC(0x30313256) | |
| static const GUID | GUID_v210 = GUID_FROM_FOURCC(0x30313276) | |
| const struct video_capture_info | vidcap_dshow_info | |
| static int * | yuv_clamp | |
Defines the exported functions for the DLL application.
Definition in file DirectShowGrabber.cpp.
| #define DEFAULT_DEVNUM 1 |
Definition at line 59 of file DirectShowGrabber.cpp.
| #define DEFAULT_FPS 15 |
Definition at line 63 of file DirectShowGrabber.cpp.
Referenced by common_init().
| #define DEFAULT_VIDEO_HEIGHT 480 |
Definition at line 62 of file DirectShowGrabber.cpp.
Referenced by common_init().
| #define DEFAULT_VIDEO_WIDTH 640 |
Definition at line 61 of file DirectShowGrabber.cpp.
Referenced by common_init().
| #define GUID_FROM_FOURCC | ( | fourcc | ) |
Definition at line 1319 of file DirectShowGrabber.cpp.
| #define HANDLE_ERR | ( | msg, | |
| ... ) |
Referenced by common_init(), get_friendly_name(), vidcap_dshow_init(), and vidcap_dshow_probe_internal().
| #define HANDLE_ERR | ( | msg, | |
| ... ) |
| #define HANDLE_ERR | ( | msg, | |
| ... ) |
| #define HANDLE_ERR_ACTION | ( | res, | |
| action, | |||
| msg, | |||
| ... ) |
Definition at line 224 of file DirectShowGrabber.cpp.
| #define MAX_STRING_LEN 1000 |
Definition at line 60 of file DirectShowGrabber.cpp.
Referenced by get_friendly_name().
| #define MAX_YUV_CLAMP 535 |
Definition at line 65 of file DirectShowGrabber.cpp.
Referenced by vidcap_dshow_init().
| #define MIN_YUV_CLAMP -276 |
Definition at line 66 of file DirectShowGrabber.cpp.
Referenced by vidcap_dshow_init().
| #define MOD_NAME "[dshow] " |
Definition at line 32 of file DirectShowGrabber.cpp.
Referenced by SampleGrabberCallback::BufferCB(), cleanup(), ErrorDescription(), GraphPause(), GraphRun(), process_args(), vidcap_dshow_done(), vidcap_dshow_get_video_desc(), vidcap_dshow_grab(), vidcap_dshow_init(), and vidcap_dshow_probe_internal().
| typedef void(* convert_t) (int width, int height, const unsigned char *in, unsigned char *out) |
Definition at line 37 of file DirectShowGrabber.cpp.
|
static |
convert from ABGR and bottom-to-top
Definition at line 1306 of file DirectShowGrabber.cpp.
References RGBA, vc_copylineRGBA, and vc_get_linesize().

|
static |
Apparently DirectShow uses bottom-to-top line ordering so we want make it top-to-bottom
Definition at line 1294 of file DirectShowGrabber.cpp.
References BGR, and vc_get_linesize().

|
static |
Definition at line 185 of file DirectShowGrabber.cpp.
References vidcap_dshow_state::captureFilter, vidcap_dshow_state::com_initialized, com_uninitialize(), vidcap_dshow_state::convert_buffer, vidcap_dshow_state::deviceName, vidcap_dshow_state::frame, vidcap_dshow_state::grabBuffer, LOG_LEVEL_VERBOSE, log_msg(), vidcap_dshow_state::mediaControl, MOD_NAME, vidcap_dshow_state::moniker, vidcap_dshow_state::nullRenderer, vidcap_dshow_state::returnBuffer, vidcap_dshow_state::returnBufferCS, vidcap_dshow_state::sampleGrabberFilter, vf_free(), and yuv_clamp.

|
static |
Definition at line 231 of file DirectShowGrabber.cpp.
References vidcap_dshow_state::captureFilter, cleanup(), com_initialize(), vidcap_dshow_state::com_initialized, vidcap_dshow_state::convert_buffer, vidcap_dshow_state::convert_YUYV_RGB, DEFAULT_FPS, DEFAULT_VIDEO_HEIGHT, DEFAULT_VIDEO_WIDTH, vidcap_dshow_state::desc, vidcap_dshow_state::devEnumerator, vidcap_dshow_state::deviceNumber, vidcap_dshow_state::filterGraph, video_desc::fps, vidcap_dshow_state::frame, vidcap_dshow_state::frames, vidcap_dshow_state::grabBuffer, vidcap_dshow_state::grabBufferLen, vidcap_dshow_state::graphBuilder, HANDLE_ERR, vidcap_dshow_state::haveNewReturnBuffer, video_desc::height, video_desc::interlacing, vidcap_dshow_state::mediaControl, vidcap_dshow_state::modeNumber, vidcap_dshow_state::moniker, MSG, vidcap_dshow_state::no_sync_source, vidcap_dshow_state::nullRenderer, PROGRESSIVE, vidcap_dshow_state::returnBuffer, vidcap_dshow_state::returnBufferCS, vidcap_dshow_state::returnBufferLen, vidcap_dshow_state::sampleGrabberFilter, vidcap_dshow_state::streamConfig, video_desc::tile_count, vidcap_dshow_state::videoInputEnumerator, video_desc::width, and yuv_clamp.
Referenced by show_help(), vidcap_dshow_init(), and vidcap_dshow_probe_internal().

|
static |
Definition at line 745 of file DirectShowGrabber.cpp.
References ConnectFilters(), and FindUnconnectedPin().

|
static |
Definition at line 733 of file DirectShowGrabber.cpp.
References FindUnconnectedPin().
Referenced by ConnectFilters(), and vidcap_dshow_init().

Definition at line 1159 of file DirectShowGrabber.cpp.
References yuv_clamp.
Referenced by convert_yuyv_rgb().
Definition at line 1169 of file DirectShowGrabber.cpp.
References convert_yuv_rgb().
Referenced by vidcap_dshow_grab().

|
static |
Definition at line 1260 of file DirectShowGrabber.cpp.
References FreeMediaType().
Referenced by vidcap_dshow_init(), and vidcap_dshow_probe_internal().

|
static |
Definition at line 51 of file DirectShowGrabber.cpp.
References LOG_LEVEL_ERROR, log_msg(), and MOD_NAME.
Referenced by GraphPause(), and GraphRun().

|
static |
Definition at line 686 of file DirectShowGrabber.cpp.
References filter(), PinHasDirection(), and PinIsConnected().
Referenced by ConnectFilters(), and ConnectFilters().

|
static |
Definition at line 1245 of file DirectShowGrabber.cpp.
Referenced by DeleteMediaType().
|
static |
Definition at line 1365 of file DirectShowGrabber.cpp.
References BitCountMap, LocateSubtype(), and pSubtype.
Referenced by vidcap_dshow_init().

|
static |
Definition at line 401 of file DirectShowGrabber.cpp.
References HANDLE_ERR, and MAX_STRING_LEN.
Referenced by vidcap_dshow_init(), and vidcap_dshow_probe_internal().
|
static |
Definition at line 1359 of file DirectShowGrabber.cpp.
References BitCountMap, LocateSubtype(), and pSubtype.
Referenced by vidcap_dshow_get_video_desc(), vidcap_dshow_init(), and vidcap_dshow_probe_internal().

|
static |
Definition at line 1370 of file DirectShowGrabber.cpp.
References BitCountMap, pName, and VIDEO_CODEC_NONE.
Referenced by process_args().
|
static |
Definition at line 797 of file DirectShowGrabber.cpp.
References FAILED.
|
static |
Definition at line 1419 of file DirectShowGrabber.cpp.
References BitCountMap, GetSubtypeNameA(), LocateSubtype(), pretty_print_fourcc(), and pSubtype.
Referenced by vidcap_dshow_init(), and vidcap_dshow_probe_internal().

|
static |
Definition at line 1412 of file DirectShowGrabber.cpp.
References BitCountMap, LocateSubtype(), and pSubtype.
Referenced by GetSubtypeName().

|
static |
Definition at line 778 of file DirectShowGrabber.cpp.
References ErrorDescription(), LOG_LEVEL_ERROR, log_msg(), and MOD_NAME.

|
static |
Definition at line 757 of file DirectShowGrabber.cpp.
References ErrorDescription(), LOG_LEVEL_ERROR, log_msg(), and MOD_NAME.

|
static |
Definition at line 1379 of file DirectShowGrabber.cpp.
References BitCountMap, pSubtype, and TRUE.
Referenced by get_conversion(), get_ug_codec(), GetSubtypeName(), and GetSubtypeNameA().
|
static |
Definition at line 1272 of file DirectShowGrabber.cpp.
References OPTIMIZED_FOR, UYVY, and vc_get_linesize().

|
static |
Definition at line 675 of file DirectShowGrabber.cpp.
Referenced by FindUnconnectedPin().
|
static |
Definition at line 660 of file DirectShowGrabber.cpp.
Referenced by FindUnconnectedPin().
|
static |
Definition at line 554 of file DirectShowGrabber.cpp.
References BGR, bug_msg(), video_desc::color_spec, vidcap_dshow_state::desc, vidcap_dshow_state::deviceName, vidcap_dshow_state::deviceNumber, video_desc::fps, get_codec_from_name(), get_ug_from_subtype_name(), video_desc::height, IS_KEY_PREFIX, LOG_LEVEL_ERROR, log_msg(), MOD_NAME, vidcap_dshow_state::modeNumber, MSG, vidcap_dshow_state::no_sync_source, VIDEO_CODEC_NONE, and video_desc::width.
Referenced by vidcap_dshow_init().

| REGISTER_MODULE | ( | dshow | , |
| & | vidcap_dshow_info, | ||
| LIBRARY_CLASS_VIDEO_CAPTURE | , | ||
| VIDEO_CAPTURE_ABI_VERSION | ) |
|
static |
Definition at line 351 of file DirectShowGrabber.cpp.
References color_printf(), common_init(), count, deleter, IF_NOT_NULL_ELSE, name, SBOLD, SRED, TERM_BOLD, TERM_RESET, UG_ASSERT_NO_FATAL, and vidcap_dshow_probe_internal().

|
static |
Definition at line 1146 of file DirectShowGrabber.cpp.
References cleanup(), LOG_LEVEL_WARNING, log_msg(), vidcap_dshow_state::mediaControl, MOD_NAME, vidcap_dshow_state::parent, state, unregister_should_exit_callback(), and vidcap_dshow_should_exit().

|
static |
Definition at line 315 of file DirectShowGrabber.cpp.
References bug_msg(), video_desc::color_spec, desc, video_desc::fps, get_ug_codec(), video_desc::height, INTERLACED_MERGED, video_desc::interlacing, LOG, LOG_LEVEL_WARNING, MOD_NAME, PROGRESSIVE, video_desc::tile_count, and video_desc::width.
Referenced by vidcap_dshow_init(), and vidcap_dshow_probe_internal().

|
static |
Definition at line 1181 of file DirectShowGrabber.cpp.
References audio, video_frame::color_spec, vidcap_dshow_state::convert_buffer, vidcap_dshow_state::convert_YUYV_RGB, convert_yuyv_rgb(), tile::data, tile::data_len, vidcap_dshow_state::deviceNumber, vidcap_dshow_state::frame, vidcap_dshow_state::frames, vidcap_dshow_state::grabBuffer, vidcap_dshow_state::grabBufferLen, vidcap_dshow_state::grabWaitCV, vidcap_dshow_state::haveNewReturnBuffer, tile::height, is_codec_opaque(), LOG, LOG_LEVEL_DEBUG, MOD_NAME, vidcap_dshow_state::returnBuffer, vidcap_dshow_state::returnBufferCS, vidcap_dshow_state::returnBufferLen, vidcap_dshow_state::should_exit, state, video_frame::tiles, vc_get_datalen(), and tile::width.

|
static |
Definition at line 826 of file DirectShowGrabber.cpp.
References BGR, vidcap_dshow_state::captureFilter, cleanup(), CLSID_NullRenderer, CLSID_SampleGrabber, video_desc::color_spec, common_init(), ConnectFilters(), vidcap_dshow_state::convert, vidcap_dshow_state::convert_buffer, vidcap_dshow_state::convert_YUYV_RGB, DeleteMediaType(), desc, vidcap_dshow_state::desc, vidcap_dshow_state::deviceName, vidcap_dshow_state::deviceNumber, vidcap_dshow_state::filterGraph, video_desc::fps, vidcap_dshow_state::frame, vidcap_dshow_state::frames, get_conversion(), get_friendly_name(), get_ug_codec(), GetSubtypeName(), vidcap_dshow_state::grabWaitCV, vidcap_dshow_state::graphBuilder, HANDLE_ERR, video_desc::height, video_desc::interlacing, is_codec_opaque(), LOG, LOG_LEVEL_ERROR, LOG_LEVEL_NOTICE, LOG_LEVEL_WARNING, log_msg(), MAX_YUV_CLAMP, vidcap_dshow_state::mediaControl, MIN_YUV_CLAMP, MOD_NAME, vidcap_dshow_state::modeNumber, vidcap_dshow_state::moniker, MSG, vidcap_dshow_state::no_sync_source, vidcap_dshow_state::nullRenderer, vidcap_dshow_state::parent, process_args(), register_should_exit_callback(), vidcap_dshow_state::returnBufferCS, vidcap_dshow_state::sampleGrabber, vidcap_dshow_state::sampleGrabberFilter, vidcap_dshow_state::SGCallback, show_help(), state, vidcap_dshow_state::streamConfig, TRUE, VC_NONE, vf_alloc_desc(), vidcap_dshow_get_video_desc(), vidcap_dshow_should_exit(), VIDCAP_FLAG_AUDIO_ANY, VIDCAP_INIT_AUDIO_NOT_SUPPORTED, VIDCAP_INIT_FAIL, VIDCAP_INIT_NOERR, VIDCAP_INIT_OK, vidcap_params_get_flags(), vidcap_params_get_fmt(), vidcap_params_get_parent(), vidcap_dshow_state::videoInputEnumerator, video_desc::width, yuv_clamp, and YUYV.

|
static |
Definition at line 549 of file DirectShowGrabber.cpp.
References count, deleter, and vidcap_dshow_probe_internal().

|
static |
Definition at line 430 of file DirectShowGrabber.cpp.
References cleanup(), codec_is_planar(), video_desc::color_spec, common_init(), count, DeleteMediaType(), deleter, desc, device_info::dev, dev_add_option(), vidcap_dshow_state::filterGraph, video_desc::fps, get_friendly_name(), get_interlacing_suffix(), get_ug_codec(), GetSubtypeName(), vidcap_dshow_state::graphBuilder, HANDLE_ERR, video_desc::height, INTERLACED_MERGED, video_desc::interlacing, is_codec_opaque(), LOG_LEVEL_WARNING, log_msg(), MOD_NAME, device_info::modes, vidcap_dshow_state::moniker, name, vidcap_dshow_state::streamConfig, ug_codec, vidcap_dshow_get_video_desc(), VIDEO_CODEC_NONE, vidcap_dshow_state::videoInputEnumerator, and video_desc::width.
Referenced by show_help(), and vidcap_dshow_probe().

|
static |
Definition at line 818 of file DirectShowGrabber.cpp.
References state.
Referenced by vidcap_dshow_done(), and vidcap_dshow_init().
| const struct { ... } BitCountMap[] |
Referenced by get_conversion(), get_ug_codec(), get_ug_from_subtype_name(), GetSubtypeName(), GetSubtypeNameA(), and LocateSubtype().
| EXTERN_C const CLSID CLSID_NullRenderer |
Definition at line 34 of file DirectShowGrabber.cpp.
Referenced by vidcap_dshow_init().
| EXTERN_C const CLSID CLSID_SampleGrabber |
Definition at line 35 of file DirectShowGrabber.cpp.
Referenced by vidcap_dshow_init().
| convert_t convert |
Definition at line 1333 of file DirectShowGrabber.cpp.
Referenced by av_to_uv_convert(), change_pixfmt(), dxt_encoder_compress_texture(), parse_num_fallback_impl(), and vidcap_ndi_grab().
|
static |
Definition at line 1327 of file DirectShowGrabber.cpp.
|
static |
Definition at line 1325 of file DirectShowGrabber.cpp.
|
static |
Definition at line 1323 of file DirectShowGrabber.cpp.
|
static |
Definition at line 1326 of file DirectShowGrabber.cpp.
|
static |
Definition at line 1324 of file DirectShowGrabber.cpp.
|
static |
Definition at line 1320 of file DirectShowGrabber.cpp.
|
static |
Definition at line 1322 of file DirectShowGrabber.cpp.
|
static |
Definition at line 1321 of file DirectShowGrabber.cpp.
| const CHAR* pName |
Definition at line 1331 of file DirectShowGrabber.cpp.
Referenced by get_ug_from_subtype_name().
| const GUID* pSubtype |
Definition at line 1330 of file DirectShowGrabber.cpp.
Referenced by get_conversion(), get_ug_codec(), GetSubtypeName(), GetSubtypeNameA(), and LocateSubtype().
| codec_t ug_codec |
Definition at line 1332 of file DirectShowGrabber.cpp.
Referenced by vidcap_dshow_probe_internal().
| const struct video_capture_info vidcap_dshow_info |
Definition at line 1428 of file DirectShowGrabber.cpp.
Referenced by cleanup(), is_library_registered(), vidcap_screen_win_grab(), and vidcap_screen_win_init().
|
static |
Definition at line 68 of file DirectShowGrabber.cpp.
Referenced by cleanup(), common_init(), convert_yuv_rgb(), and vidcap_dshow_init().