Browse Source

win-dshow: Add support for devices that relay rotation

Adds support for devices that can relay rotation, such as the Logitech
StreamCam.
jp9000 6 years ago
parent
commit
07089873fc
2 changed files with 11 additions and 4 deletions
  1. 1 1
      plugins/win-dshow/libdshowcapture
  2. 10 3
      plugins/win-dshow/win-dshow.cpp

+ 1 - 1
plugins/win-dshow/libdshowcapture

@@ -1 +1 @@
-Subproject commit 4c6e70a2ab6bc5289340b17c580085bec3f71566
+Subproject commit 03fbb3814b2ad678f5be4b23b8ca05fb4172e12e

+ 10 - 3
plugins/win-dshow/win-dshow.cpp

@@ -191,6 +191,7 @@ struct DShowInput {
 	video_range_type range;
 	obs_source_frame2 frame;
 	obs_source_audio audio;
+	long lastRotation = 0;
 
 	WinHandle semaphore;
 	WinHandle activated_event;
@@ -269,7 +270,8 @@ struct DShowInput {
 				size_t size, long long ts);
 
 	void OnVideoData(const VideoConfig &config, unsigned char *data,
-			 size_t size, long long startTime, long long endTime);
+			 size_t size, long long startTime, long long endTime,
+			 long rotation);
 	void OnAudioData(const AudioConfig &config, unsigned char *data,
 			 size_t size, long long startTime, long long endTime);
 
@@ -518,7 +520,7 @@ void DShowInput::OnEncodedVideoData(enum AVCodecID id, unsigned char *data,
 
 void DShowInput::OnVideoData(const VideoConfig &config, unsigned char *data,
 			     size_t size, long long startTime,
-			     long long endTime)
+			     long long endTime, long rotation)
 {
 	if (videoConfig.format == VideoFormat::H264) {
 		OnEncodedVideoData(AV_CODEC_ID_H264, data, size, startTime);
@@ -590,6 +592,11 @@ void DShowInput::OnVideoData(const VideoConfig &config, unsigned char *data,
 		return;
 	}
 
+	if (rotation != lastRotation) {
+		lastRotation = rotation;
+		obs_source_set_async_rotation(source, rotation);
+	}
+
 	obs_source_output_video2(source, &frame);
 
 	UNUSED_PARAMETER(endTime); /* it's the enndd tiimmes! */
@@ -936,7 +943,7 @@ bool DShowInput::UpdateVideoConfig(obs_data_t *settings)
 	videoConfig.callback = std::bind(&DShowInput::OnVideoData, this,
 					 placeholders::_1, placeholders::_2,
 					 placeholders::_3, placeholders::_4,
-					 placeholders::_5);
+					 placeholders::_5, placeholders::_6);
 
 	videoConfig.format = videoConfig.internalFormat;