⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 267366 in webkit


Ignore:
Timestamp:
Sep 21, 2020, 1:57:17 PM (6 years ago)
Author:
youenn@apple.com
Message:

[iOS] MediaRecorder incorrect screen orientation handling
https://bugs.webkit.org/show_bug.cgi?id=198912
<rdar://problem/51802521>

Reviewed by Eric Carlson.

Source/WebCore:

Update MediaRecorderPrivateWriterCocoa to pass a MediaSample down to handle rotation.
Set AVAssetWriterInput transform according the first MediaSample rotation value.

Test: http/wpt/mediarecorder/video-rotation.html

  • platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp:

(WebCore::MediaRecorderPrivateAVFImpl::videoSampleAvailable):

  • platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h:
  • platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm:

(WebCore::MediaRecorderPrivateWriter::appendVideoSampleBuffer):

Source/WebKit:

  • GPUProcess/webrtc/RemoteMediaRecorder.cpp:

(WebKit::RemoteMediaRecorder::videoSampleAvailable):

LayoutTests:

  • http/wpt/mediarecorder/video-rotation-expected.txt: Added.
  • http/wpt/mediarecorder/video-rotation.html: Added.
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r267362 r267366  
     12020-09-21  Youenn Fablet  <youenn@apple.com>
     2
     3        [iOS] MediaRecorder incorrect screen orientation handling
     4        https://bugs.webkit.org/show_bug.cgi?id=198912
     5        <rdar://problem/51802521>
     6
     7        Reviewed by Eric Carlson.
     8
     9        * http/wpt/mediarecorder/video-rotation-expected.txt: Added.
     10        * http/wpt/mediarecorder/video-rotation.html: Added.
     11
    1122020-09-20  Darin Adler  <darin@apple.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r267364 r267366  
     12020-09-21  Youenn Fablet  <youenn@apple.com>
     2
     3        [iOS] MediaRecorder incorrect screen orientation handling
     4        https://bugs.webkit.org/show_bug.cgi?id=198912
     5        <rdar://problem/51802521>
     6
     7        Reviewed by Eric Carlson.
     8
     9        Update MediaRecorderPrivateWriterCocoa to pass a MediaSample down to handle rotation.
     10        Set AVAssetWriterInput transform according the first MediaSample rotation value.
     11
     12        Test: http/wpt/mediarecorder/video-rotation.html
     13
     14        * platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp:
     15        (WebCore::MediaRecorderPrivateAVFImpl::videoSampleAvailable):
     16        * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h:
     17        * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm:
     18        (WebCore::MediaRecorderPrivateWriter::appendVideoSampleBuffer):
     19
    1202020-09-21  Keith Miller  <keith_miller@apple.com>
    221
  • trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp

    r266116 r267366  
    7171void MediaRecorderPrivateAVFImpl::videoSampleAvailable(MediaSample& sampleBuffer)
    7272{
    73     m_writer->appendVideoSampleBuffer(sampleBuffer.platformSample().sample.cmSampleBuffer);
     73    m_writer->appendVideoSampleBuffer(sampleBuffer);
    7474}
    7575
  • trunk/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h

    r266116 r267366  
    5757class AudioSampleBufferCompressor;
    5858class AudioStreamDescription;
     59class MediaSample;
    5960class MediaStreamTrackPrivate;
    6061class PlatformAudioData;
     
    6768    ~MediaRecorderPrivateWriter();
    6869
    69     void appendVideoSampleBuffer(CMSampleBufferRef);
     70    void appendVideoSampleBuffer(MediaSample&);
    7071    void appendAudioSampleBuffer(const PlatformAudioData&, const AudioStreamDescription&, const WTF::MediaTime&, size_t);
    7172    void stopRecording();
     
    130131    bool m_isFlushingSamples { false };
    131132    bool m_shouldStopAfterFlushingSamples { false };
     133    bool m_firstVideoFrame { false };
    132134};
    133135
  • trunk/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm

    r266116 r267366  
    422422}
    423423
    424 void MediaRecorderPrivateWriter::appendVideoSampleBuffer(CMSampleBufferRef sampleBuffer)
    425 {
     424void MediaRecorderPrivateWriter::appendVideoSampleBuffer(MediaSample& sample)
     425{
     426    if (!m_firstVideoFrame) {
     427        m_firstVideoFrame = true;
     428        if (sample.videoRotation() != MediaSample::VideoRotation::None || sample.videoMirrored()) {
     429            auto videoTransform = CGAffineTransformMakeRotation(static_cast<int>(sample.videoRotation()) * M_PI / 180);
     430            if (sample.videoMirrored())
     431                videoTransform = CGAffineTransformScale(videoTransform, -1, 1);
     432            m_videoAssetWriterInput.get().transform = videoTransform;
     433        }
     434    }
    426435    // FIXME: We should not set the timestamps if they are already set.
    427     if (auto bufferWithCurrentTime = copySampleBufferWithCurrentTimeStamp(sampleBuffer))
     436    if (auto bufferWithCurrentTime = copySampleBufferWithCurrentTimeStamp(sample.platformSample().sample.cmSampleBuffer))
    428437        m_videoCompressor->addSampleBuffer(bufferWithCurrentTime.get());
    429438}
  • trunk/Source/WebKit/ChangeLog

    r267364 r267366  
     12020-09-21  Youenn Fablet  <youenn@apple.com>
     2
     3        [iOS] MediaRecorder incorrect screen orientation handling
     4        https://bugs.webkit.org/show_bug.cgi?id=198912
     5        <rdar://problem/51802521>
     6
     7        Reviewed by Eric Carlson.
     8
     9        * GPUProcess/webrtc/RemoteMediaRecorder.cpp:
     10        (WebKit::RemoteMediaRecorder::videoSampleAvailable):
     11
    1122020-09-21  Keith Miller  <keith_miller@apple.com>
    213
  • trunk/Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorder.cpp

    r267237 r267366  
    119119    }
    120120
    121     m_writer->appendVideoSampleBuffer(sampleBuffer->platformSample().sample.cmSampleBuffer);
     121    m_writer->appendVideoSampleBuffer(*sampleBuffer);
    122122}
    123123
Note: See TracChangeset for help on using the changeset viewer.