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}
This commit is contained in:
nisse 2017-02-20 23:27:37 -08:00 committed by Commit bot
parent 7e560a1bb7
commit 1e32122168
6 changed files with 66 additions and 108 deletions

View File

@ -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;
}

View File

@ -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<int32_t>(_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

View File

@ -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;
}

View File

@ -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;

View File

@ -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<I420Buffer> 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<I420Buffer> 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;
}

View File

@ -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: