haikuwebkit/LayoutTests/webrtc/video-h264.html

116 lines
3.7 KiB
HTML
Raw Permalink Normal View History

Call was negotiated with H264 Base Profile 42e01f but encoded in High Profile https://bugs.webkit.org/show_bug.cgi?id=195124 <rdar://problem/48453085> Reviewed by Eric Carlson. Source/ThirdParty/libwebrtc: Use VTB directly instead of VCP when baseline is requested. For platforms supporting the VCP-in-VTB API, use VCP for high profile, VTB for baseline. For platforms not supporting the VCP-in-VTB API, use regular VTB for both baseline and high profile. On MacOS, if VTB session creation fails, use VCP as a fallback. Keep VTB-only code path for non internal builds. * Source/webrtc/sdk/WebKit/EncoderUtilities.h: Removed. * Source/webrtc/sdk/WebKit/VideoProcessingSoftLink.h: * Source/webrtc/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm: (-[RTCSingleVideoEncoderH264 initWithCodecInfo:simulcastIndex:]): (-[RTCSingleVideoEncoderH264 hasCompressionSession]): (-[RTCSingleVideoEncoderH264 encode:codecSpecificInfo:frameTypes:]): (-[RTCSingleVideoEncoderH264 resetCompressionSessionIfNeededWithFrame:]): (-[RTCSingleVideoEncoderH264 resetCompressionSessionWithPixelFormat:]): (-[RTCSingleVideoEncoderH264 configureCompressionSession]): (-[RTCSingleVideoEncoderH264 destroyCompressionSession]): (-[RTCSingleVideoEncoderH264 setEncoderBitrateBps:]): * Source/webrtc/sdk/objc/components/video_codec/helpers.cc: * Source/webrtc/sdk/objc/components/video_codec/helpers.h: LayoutTests: * webrtc/video-h264-expected.txt: Added. * webrtc/video-h264.html: Added. Canonical link: https://commits.webkit.org/212691@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@246263 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-06-10 15:59:14 +00:00
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Testing H264 baseline and high profile</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
</head>
<body>
<video id="video" autoplay=""></video>
<canvas id="canvas" width="640" height="480"></canvas>
<script src ="routines.js"></script>
<script>
function grabFrameData(x, y, w, h)
{
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
canvas.getContext('2d').drawImage(video, x, y, w, h, x, y, w, h);
return canvas.getContext('2d').getImageData(x, y, w, h).data;
}
function testImage()
{
const data = grabFrameData(10, 325, 250, 1);
var index = 20;
assert_true(data[index] < 100);
assert_true(data[index + 1] < 100);
assert_true(data[index + 2] < 100);
index = 80;
assert_true(data[index] > 200);
assert_true(data[index + 1] > 200);
assert_true(data[index + 2] > 200);
index += 80;
assert_true(data[index] > 200);
assert_true(data[index + 1] > 200);
assert_true(data[index + 2] < 100);
}
promise_test(async (test) => {
if (window.testRunner)
testRunner.setUserMediaPermission(true);
const localStream = await navigator.mediaDevices.getUserMedia({video: true});
const stream = await new Promise((resolve, reject) => {
createConnections((firstConnection) => {
firstConnection.addTrack(localStream.getVideoTracks()[0], localStream);
}, (secondConnection) => {
secondConnection.ontrack = (trackEvent) => {
resolve(trackEvent.streams[0]);
};
}, { observeOffer : (offer) => {
offer.sdp = offer.sdp.replace("640c1f", "42e01f");
return offer;
}
});
setTimeout(() => reject("Test timed out"), 5000);
});
video.srcObject = stream;
await video.play();
testImage();
}, "Baseline H264");
promise_test(async (test) => {
if (window.testRunner)
testRunner.setUserMediaPermission(true);
const localStream = await navigator.mediaDevices.getUserMedia({video: true});
const stream = await new Promise((resolve, reject) => {
createConnections((firstConnection) => {
firstConnection.addTrack(localStream.getVideoTracks()[0], localStream);
}, (secondConnection) => {
secondConnection.ontrack = (trackEvent) => {
resolve(trackEvent.streams[0]);
};
}, { observeOffer : (offer) => {
offer.sdp = offer.sdp.replace("42e01f", "640c1f");
return offer;
}
});
setTimeout(() => reject("Test timed out"), 5000);
});
video.srcObject = stream;
await video.play();
testImage();
}, "High H264");
test(() => {
let codecs = RTCRtpSender.getCapabilities("video").codecs;
codecs = codecs.filter(codec => codec.mimeType === "video/H264");
let sdpFmtpLines = codecs.map(codec => codec.sdpFmtpLine);
assert_true(codecs.some(codec => codec.sdpFmtpLine.includes('42e01f')));
assert_true(codecs.some(codec => codec.sdpFmtpLine.includes('640c1f')));
}, "H264 in RTCRtpSender.getCapabilities");
test(() => {
let codecs = RTCRtpReceiver.getCapabilities("video").codecs;
codecs = codecs.filter(codec => codec.mimeType === "video/H264");
let sdpFmtpLines = codecs.map(codec => codec.sdpFmtpLine);
assert_true(codecs.some(codec => codec.sdpFmtpLine.includes('42e01f')));
assert_true(codecs.some(codec => codec.sdpFmtpLine.includes('640c1f')));
}, "H264 in RTCRtpReceiver.getCapabilities");
Call was negotiated with H264 Base Profile 42e01f but encoded in High Profile https://bugs.webkit.org/show_bug.cgi?id=195124 <rdar://problem/48453085> Reviewed by Eric Carlson. Source/ThirdParty/libwebrtc: Use VTB directly instead of VCP when baseline is requested. For platforms supporting the VCP-in-VTB API, use VCP for high profile, VTB for baseline. For platforms not supporting the VCP-in-VTB API, use regular VTB for both baseline and high profile. On MacOS, if VTB session creation fails, use VCP as a fallback. Keep VTB-only code path for non internal builds. * Source/webrtc/sdk/WebKit/EncoderUtilities.h: Removed. * Source/webrtc/sdk/WebKit/VideoProcessingSoftLink.h: * Source/webrtc/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm: (-[RTCSingleVideoEncoderH264 initWithCodecInfo:simulcastIndex:]): (-[RTCSingleVideoEncoderH264 hasCompressionSession]): (-[RTCSingleVideoEncoderH264 encode:codecSpecificInfo:frameTypes:]): (-[RTCSingleVideoEncoderH264 resetCompressionSessionIfNeededWithFrame:]): (-[RTCSingleVideoEncoderH264 resetCompressionSessionWithPixelFormat:]): (-[RTCSingleVideoEncoderH264 configureCompressionSession]): (-[RTCSingleVideoEncoderH264 destroyCompressionSession]): (-[RTCSingleVideoEncoderH264 setEncoderBitrateBps:]): * Source/webrtc/sdk/objc/components/video_codec/helpers.cc: * Source/webrtc/sdk/objc/components/video_codec/helpers.h: LayoutTests: * webrtc/video-h264-expected.txt: Added. * webrtc/video-h264.html: Added. Canonical link: https://commits.webkit.org/212691@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@246263 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-06-10 15:59:14 +00:00
</script>
</body>
</html>