From 1e3212216816cce68d873aa3ce5dea87f40414d4 Mon Sep 17 00:00:00 2001 From: nisse Date: Mon, 20 Feb 2017 23:27:37 -0800 Subject: [PATCH] Delete VideoCaptureCapability::codecType and related logic. The video_capture module includes remnants of support for cameras producing encoded frames. However, this seems to be unused, and is explicitly not supported by VideoCaptureImpl::IncomingFrame. BUG=None Review-Url: https://codereview.webrtc.org/2668693008 Cr-Commit-Position: refs/heads/master@{#16732} --- webrtc/media/engine/webrtcvideocapturer.cc | 1 - .../modules/video_capture/device_info_impl.cc | 52 +++------ .../video_capture/objc/device_info_objc.mm | 3 - .../video_capture/video_capture_defines.h | 4 - .../video_capture/video_capture_impl.cc | 109 ++++++++---------- .../video_capture/windows/sink_filter_ds.cc | 5 - 6 files changed, 66 insertions(+), 108 deletions(-) diff --git a/webrtc/media/engine/webrtcvideocapturer.cc b/webrtc/media/engine/webrtcvideocapturer.cc index d8419d2bd5..5aac3f81ac 100644 --- a/webrtc/media/engine/webrtcvideocapturer.cc +++ b/webrtc/media/engine/webrtcvideocapturer.cc @@ -95,7 +95,6 @@ static bool FormatToCapability(const VideoFormat& format, cap->height = format.height; cap->maxFPS = VideoFormat::IntervalToFps(format.interval); cap->rawType = webrtc_type; - cap->codecType = webrtc::kVideoCodecUnknown; cap->interlaced = false; return true; } diff --git a/webrtc/modules/video_capture/device_info_impl.cc b/webrtc/modules/video_capture/device_info_impl.cc index e2caeaa58f..472db49d3f 100644 --- a/webrtc/modules/video_capture/device_info_impl.cc +++ b/webrtc/modules/video_capture/device_info_impl.cc @@ -154,7 +154,6 @@ int32_t DeviceInfoImpl::GetBestMatchedCapability( int32_t bestHeight = 0; int32_t bestFrameRate = 0; RawVideoType bestRawType = kVideoUnknown; - webrtc::VideoCodecType bestCodecType = webrtc::kVideoCodecUnknown; const int32_t numberOfCapabilies = static_cast(_captureCapabilities.size()); @@ -201,7 +200,6 @@ int32_t DeviceInfoImpl::GetBestMatchedCapability( || capability.rawType == kVideoYUY2 || capability.rawType == kVideoYV12)) { - bestCodecType = capability.codecType; bestRawType = capability.rawType; bestformatIndex = tmp; } @@ -210,54 +208,36 @@ int32_t DeviceInfoImpl::GetBestMatchedCapability( && capability.width == requested.width && capability.maxFPS >= requested.maxFPS) { - if (capability.codecType == requested.codecType - && bestCodecType != requested.codecType) - { - bestCodecType = capability.codecType; - bestformatIndex = tmp; - } + bestformatIndex = tmp; } } else // Better frame rate { - if (requested.codecType == capability.codecType) - { - - bestWidth = capability.width; - bestHeight = capability.height; - bestFrameRate = capability.maxFPS; - bestCodecType = capability.codecType; - bestRawType = capability.rawType; - bestformatIndex = tmp; - } + bestWidth = capability.width; + bestHeight = capability.height; + bestFrameRate = capability.maxFPS; + bestRawType = capability.rawType; + bestformatIndex = tmp; } } } else // Better width than previously { - if (requested.codecType == capability.codecType) - { - bestWidth = capability.width; - bestHeight = capability.height; - bestFrameRate = capability.maxFPS; - bestCodecType = capability.codecType; - bestRawType = capability.rawType; - bestformatIndex = tmp; - } + bestWidth = capability.width; + bestHeight = capability.height; + bestFrameRate = capability.maxFPS; + bestRawType = capability.rawType; + bestformatIndex = tmp; } }// else width no good } else // Better height { - if (requested.codecType == capability.codecType) - { - bestWidth = capability.width; - bestHeight = capability.height; - bestFrameRate = capability.maxFPS; - bestCodecType = capability.codecType; - bestRawType = capability.rawType; - bestformatIndex = tmp; - } + bestWidth = capability.width; + bestHeight = capability.height; + bestFrameRate = capability.maxFPS; + bestRawType = capability.rawType; + bestformatIndex = tmp; } }// else height not good }//end for diff --git a/webrtc/modules/video_capture/objc/device_info_objc.mm b/webrtc/modules/video_capture/objc/device_info_objc.mm index 5639380163..30a07b973b 100644 --- a/webrtc/modules/video_capture/objc/device_info_objc.mm +++ b/webrtc/modules/video_capture/objc/device_info_objc.mm @@ -61,21 +61,18 @@ capability.height = 288; capability.maxFPS = 30; capability.rawType = webrtc::kVideoNV12; - capability.codecType = webrtc::kVideoCodecUnknown; capability.interlaced = false; } else if ([preset isEqualToString:AVCaptureSessionPreset640x480]) { capability.width = 640; capability.height = 480; capability.maxFPS = 30; capability.rawType = webrtc::kVideoNV12; - capability.codecType = webrtc::kVideoCodecUnknown; capability.interlaced = false; } else if ([preset isEqualToString:AVCaptureSessionPreset1280x720]) { capability.width = 1280; capability.height = 720; capability.maxFPS = 30; capability.rawType = webrtc::kVideoNV12; - capability.codecType = webrtc::kVideoCodecUnknown; capability.interlaced = false; } diff --git a/webrtc/modules/video_capture/video_capture_defines.h b/webrtc/modules/video_capture/video_capture_defines.h index b7ab61a07a..90693ad2fe 100644 --- a/webrtc/modules/video_capture/video_capture_defines.h +++ b/webrtc/modules/video_capture/video_capture_defines.h @@ -32,7 +32,6 @@ struct VideoCaptureCapability int32_t height; int32_t maxFPS; RawVideoType rawType; - VideoCodecType codecType; bool interlaced; VideoCaptureCapability() @@ -41,7 +40,6 @@ struct VideoCaptureCapability height = 0; maxFPS = 0; rawType = kVideoUnknown; - codecType = kVideoCodecUnknown; interlaced = false; } ; @@ -55,8 +53,6 @@ struct VideoCaptureCapability return true; if (rawType != other.rawType) return true; - if (codecType != other.codecType) - return true; if (interlaced != other.interlaced) return true; return false; diff --git a/webrtc/modules/video_capture/video_capture_impl.cc b/webrtc/modules/video_capture/video_capture_impl.cc index 6b50205c32..ead2b1568a 100644 --- a/webrtc/modules/video_capture/video_capture_impl.cc +++ b/webrtc/modules/video_capture/video_capture_impl.cc @@ -93,7 +93,6 @@ VideoCaptureImpl::VideoCaptureImpl() _requestedCapability.height = kDefaultHeight; _requestedCapability.maxFPS = 30; _requestedCapability.rawType = kVideoI420; - _requestedCapability.codecType = kVideoCodecUnknown; memset(_incomingFrameTimesNanos, 0, sizeof(_incomingFrameTimesNanos)); } @@ -139,68 +138,60 @@ int32_t VideoCaptureImpl::IncomingFrame( TRACE_EVENT1("webrtc", "VC::IncomingFrame", "capture_time", captureTime); - if (frameInfo.codecType == kVideoCodecUnknown) + // Not encoded, convert to I420. + const VideoType commonVideoType = + RawVideoTypeToCommonVideoVideoType(frameInfo.rawType); + + if (frameInfo.rawType != kVideoMJPEG && + CalcBufferSize(commonVideoType, width, + abs(height)) != videoFrameLength) { - // Not encoded, convert to I420. - const VideoType commonVideoType = - RawVideoTypeToCommonVideoVideoType(frameInfo.rawType); - - if (frameInfo.rawType != kVideoMJPEG && - CalcBufferSize(commonVideoType, width, - abs(height)) != videoFrameLength) - { - LOG(LS_ERROR) << "Wrong incoming frame length."; - return -1; - } - - int stride_y = width; - int stride_uv = (width + 1) / 2; - int target_width = width; - int target_height = height; - - // SetApplyRotation doesn't take any lock. Make a local copy here. - bool apply_rotation = apply_rotation_; - - if (apply_rotation) { - // Rotating resolution when for 90/270 degree rotations. - if (_rotateFrame == kVideoRotation_90 || - _rotateFrame == kVideoRotation_270) { - target_width = abs(height); - target_height = width; - } - } - - // Setting absolute height (in case it was negative). - // In Windows, the image starts bottom left, instead of top left. - // Setting a negative source height, inverts the image (within LibYuv). - - // TODO(nisse): Use a pool? - rtc::scoped_refptr buffer = I420Buffer::Create( - target_width, abs(target_height), stride_y, stride_uv, stride_uv); - const int conversionResult = ConvertToI420( - commonVideoType, videoFrame, 0, 0, // No cropping - width, height, videoFrameLength, - apply_rotation ? _rotateFrame : kVideoRotation_0, buffer.get()); - if (conversionResult < 0) - { - LOG(LS_ERROR) << "Failed to convert capture frame from type " - << frameInfo.rawType << "to I420."; - return -1; - } - - VideoFrame captureFrame( - buffer, 0, rtc::TimeMillis(), - !apply_rotation ? _rotateFrame : kVideoRotation_0); - captureFrame.set_ntp_time_ms(captureTime); - - DeliverCapturedFrame(captureFrame); - } - else // Encoded format - { - assert(false); + LOG(LS_ERROR) << "Wrong incoming frame length."; return -1; } + int stride_y = width; + int stride_uv = (width + 1) / 2; + int target_width = width; + int target_height = height; + + // SetApplyRotation doesn't take any lock. Make a local copy here. + bool apply_rotation = apply_rotation_; + + if (apply_rotation) { + // Rotating resolution when for 90/270 degree rotations. + if (_rotateFrame == kVideoRotation_90 || + _rotateFrame == kVideoRotation_270) { + target_width = abs(height); + target_height = width; + } + } + + // Setting absolute height (in case it was negative). + // In Windows, the image starts bottom left, instead of top left. + // Setting a negative source height, inverts the image (within LibYuv). + + // TODO(nisse): Use a pool? + rtc::scoped_refptr buffer = I420Buffer::Create( + target_width, abs(target_height), stride_y, stride_uv, stride_uv); + const int conversionResult = ConvertToI420( + commonVideoType, videoFrame, 0, 0, // No cropping + width, height, videoFrameLength, + apply_rotation ? _rotateFrame : kVideoRotation_0, buffer.get()); + if (conversionResult < 0) + { + LOG(LS_ERROR) << "Failed to convert capture frame from type " + << frameInfo.rawType << "to I420."; + return -1; + } + + VideoFrame captureFrame( + buffer, 0, rtc::TimeMillis(), + !apply_rotation ? _rotateFrame : kVideoRotation_0); + captureFrame.set_ntp_time_ms(captureTime); + + DeliverCapturedFrame(captureFrame); + return 0; } diff --git a/webrtc/modules/video_capture/windows/sink_filter_ds.cc b/webrtc/modules/video_capture/windows/sink_filter_ds.cc index 22171d7876..7e99556081 100644 --- a/webrtc/modules/video_capture/windows/sink_filter_ds.cc +++ b/webrtc/modules/video_capture/windows/sink_filter_ds.cc @@ -87,11 +87,6 @@ CaptureInputPin::GetMediaType (IN int iPosition, OUT CMediaType * pmt) pmt->SetTemporalCompression(FALSE); int32_t positionOffset=1; - if(_requestedCapability.codecType!=kVideoCodecUnknown) - { - positionOffset=0; - } - switch (iPosition+positionOffset) { case 0: