• Rahul Singh's avatar
    Video capture: Fix camera rotation for Windows devices locked in · 687efc51
    Rahul Singh authored
    non-default orientation
    
    Problem: When Windows tablet devices are locked in a non-default
    orientation, the video capture stream is incorrectly rotated.
    
    Cause: We always return a camera rotation of 0 when auto-rotation is
    turned off. For devices locked in non-default orientations this leads
    to incorrect camera rotation.
    
    Fix: This change removes the IsAutoRotationEnabled() check inside
    GetCameraRotation(). It also adds a new base::Optional<int> member
    camera_rotation_ in video_capture_device_mf_win.cc and
    video_capture_device_win.cc.
    
    When a frame is received, if camera_rotation_ doesn't have a value OR
    auto rotation is enabled, we call GetCameraRotation() and cache the
    non-negative returned value in camera_rotation_. This enables us to
    calculate and save the correct camera rotation when the first frame is
    received. Further, if auto rotation is turned off during the capture
    session, we'll be able to use the cached value to keep the
    camera correctly rotated.
    
    Testing: I added a test in video_capture_device_mf_win_unittest.cc to
    verify that GetCameraRotation() is called and |camera_rotation_| is
    populated when MFVideoCallback::OnSample() is invoked.
    
    I also tested this change with both a naturally landscape and a
    naturally portrait Windows tablet device locked in all possible
    orientations. In each case the camera was correctly rotated.
    
    Bug: 1134801
    Change-Id: Ib1b6f1a4bb388b1390e5a257686c3b8a417a2a9c
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2447036Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
    Commit-Queue: Rahul Singh <rahsin@microsoft.com>
    Cr-Commit-Position: refs/heads/master@{#815223}
    687efc51
video_capture_device_win.h 5.65 KB