Changeset 240000 in webkit


Ignore:
Timestamp:
Jan 15, 2019 1:21:02 PM (5 years ago)
Author:
youenn@apple.com
Message:

Correctly handle rotation for local video playback
https://bugs.webkit.org/show_bug.cgi?id=193412

Reviewed by Eric Carlson.

Update AVVideoCaptureSource to compute the size given to settings after rotating the sample.
This ensures computing the size of video elements appropriately.
Also makes sure to notify observers of size change whenever rotation happens as settings() call will provide a different size.
Covered by manual testing as we do not have yet emulation of local capture with rotation.

  • platform/mediastream/RealtimeMediaSource.cpp:

(WebCore::RealtimeMediaSource::setIntrinsicSize):

  • platform/mediastream/mac/AVVideoCaptureSource.mm:

(WebCore::AVVideoCaptureSource::settings):
(WebCore::AVVideoCaptureSource::computeSampleRotation):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r239993 r240000  
     12019-01-15  Youenn Fablet  <youenn@apple.com>
     2
     3        Correctly handle rotation for local video playback
     4        https://bugs.webkit.org/show_bug.cgi?id=193412
     5
     6        Reviewed by Eric Carlson.
     7
     8        Update AVVideoCaptureSource to compute the size given to settings after rotating the sample.
     9        This ensures computing the size of video elements appropriately.
     10        Also makes sure to notify observers of size change whenever rotation happens as settings() call will provide a different size.
     11        Covered by manual testing as we do not have yet emulation of local capture with rotation.
     12
     13        * platform/mediastream/RealtimeMediaSource.cpp:
     14        (WebCore::RealtimeMediaSource::setIntrinsicSize):
     15        * platform/mediastream/mac/AVVideoCaptureSource.mm:
     16        (WebCore::AVVideoCaptureSource::settings):
     17        (WebCore::AVVideoCaptureSource::computeSampleRotation):
     18
    1192019-01-15  Chris Dumez  <cdumez@apple.com>
    220
  • trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp

    r239427 r240000  
    891891        return;
    892892
     893    auto currentSize = this->size();
    893894    m_intrinsicSize = size;
    894895
    895     if (m_intrinsicSize != m_size)
     896    if (currentSize != this->size())
    896897        notifySettingsDidChangeObservers({ RealtimeMediaSourceSettings::Flag::Width, RealtimeMediaSourceSettings::Flag::Height });
    897898}
  • trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm

    r239531 r240000  
    261261
    262262    settings.setFrameRate(frameRate());
    263     auto& size = this->size();
     263
     264    auto size = this->size();
     265    if (m_sampleRotation == MediaSample::VideoRotation::Left || m_sampleRotation == MediaSample::VideoRotation::Right)
     266        size = size.transposedSize();
     267   
    264268    settings.setWidth(size.width());
    265269    settings.setHeight(size.height());
     
    502506{
    503507    bool frontCamera = [device() position] == AVCaptureDevicePositionFront;
     508    MediaSample::VideoRotation sampleRotation;
    504509    switch (m_sensorOrientation - m_deviceOrientation) {
    505510    case 0:
    506         m_sampleRotation = MediaSample::VideoRotation::None;
     511        sampleRotation = MediaSample::VideoRotation::None;
    507512        break;
    508513    case 180:
    509514    case -180:
    510         m_sampleRotation = MediaSample::VideoRotation::UpsideDown;
     515        sampleRotation = MediaSample::VideoRotation::UpsideDown;
    511516        break;
    512517    case 90:
    513         m_sampleRotation = frontCamera ? MediaSample::VideoRotation::Left : MediaSample::VideoRotation::Right;
     518        sampleRotation = frontCamera ? MediaSample::VideoRotation::Left : MediaSample::VideoRotation::Right;
    514519        break;
    515520    case -90:
    516521    case -270:
    517         m_sampleRotation = frontCamera ? MediaSample::VideoRotation::Right : MediaSample::VideoRotation::Left;
     522        sampleRotation = frontCamera ? MediaSample::VideoRotation::Right : MediaSample::VideoRotation::Left;
    518523        break;
    519524    default:
    520525        ASSERT_NOT_REACHED();
    521         m_sampleRotation = MediaSample::VideoRotation::None;
    522     }
     526        sampleRotation = MediaSample::VideoRotation::None;
     527    }
     528    if (sampleRotation == m_sampleRotation)
     529        return;
     530
     531    m_sampleRotation = sampleRotation;
     532    notifySettingsDidChangeObservers({ RealtimeMediaSourceSettings::Flag::Width, RealtimeMediaSourceSettings::Flag::Height });
    523533}
    524534
Note: See TracChangeset for help on using the changeset viewer.