This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[video_player_avfoundation] Applies the standardized transform for videos with different orientations #5069
Merged
fluttergithubbot
merged 11 commits into
flutter:main
from
AlexV525:fix-ios-video-transform
Apr 19, 2022
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f69f79e
Apply the correct transform for videos with different orientations
AlexV525 85da558
✅ `testTransformFixByOrientation` -> `validateTransformFixForOrientat…
AlexV525 bc4b06d
🎨 Extra blank lines
AlexV525 7a74c2a
💡 Rewrite and move around comments
AlexV525 2ae271b
♻️ Rewrite the category as a C function
AlexV525 7c91a3f
Apply suggestions from code review
AlexV525 1c7bc9a
♻️ Rewrite the category as a C function x2
AlexV525 2bb2f41
🎨 Format fix
AlexV525 e452c89
Apply suggestions from code review
AlexV525 07cb30e
💡 Remove the comment about iOS 14+
AlexV525 b801da1
Apply suggestions from code review
AlexV525 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
packages/video_player/video_player_avfoundation/ios/Classes/AVAssetTrackUtils.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#import <AVFoundation/AVFoundation.h> | ||
|
||
/** | ||
* Returns a standardized transform | ||
* according to the orientation of the track. | ||
* | ||
* Note: https://stackoverflow.com/questions/64161544 | ||
* `AVAssetTrack.preferredTransform` can have wrong `tx` and `ty`. | ||
AlexV525 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*/ | ||
CGAffineTransform FLTGetStandardizedTransformForTrack(AVAssetTrack* track); |
46 changes: 46 additions & 0 deletions
46
packages/video_player/video_player_avfoundation/ios/Classes/AVAssetTrackUtils.m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#import <AVFoundation/AVFoundation.h> | ||
|
||
CGAffineTransform FLTGetStandardizedTransformForTrack(AVAssetTrack *track) { | ||
CGAffineTransform t = track.preferredTransform; | ||
CGSize size = track.naturalSize; | ||
// Each case of control flows corresponds to a specific | ||
// `UIImageOrientation`, with 8 cases in total. | ||
if (t.a == 1 && t.b == 0 && t.c == 0 && t.d == 1) { | ||
// UIImageOrientationUp | ||
t.tx = 0; | ||
t.ty = 0; | ||
} else if (t.a == -1 && t.b == 0 && t.c == 0 && t.d == -1) { | ||
// UIImageOrientationDown | ||
t.tx = size.width; | ||
t.ty = size.height; | ||
} else if (t.a == 0 && t.b == -1 && t.c == 1 && t.d == 0) { | ||
// UIImageOrientationLeft | ||
t.tx = 0; | ||
t.ty = size.width; | ||
} else if (t.a == 0 && t.b == 1 && t.c == -1 && t.d == 0) { | ||
// UIImageOrientationRight | ||
t.tx = size.height; | ||
t.ty = 0; | ||
} else if (t.a == -1 && t.b == 0 && t.c == 0 && t.d == 1) { | ||
// UIImageOrientationUpMirrored | ||
t.tx = size.width; | ||
t.ty = 0; | ||
} else if (t.a == 1 && t.b == 0 && t.c == 0 && t.d == -1) { | ||
// UIImageOrientationDownMirrored | ||
t.tx = 0; | ||
t.ty = size.height; | ||
} else if (t.a == 0 && t.b == -1 && t.c == -1 && t.d == 0) { | ||
// UIImageOrientationLeftMirrored | ||
t.tx = size.height; | ||
t.ty = size.width; | ||
} else if (t.a == 0 && t.b == 1 && t.c == 1 && t.d == 0) { | ||
// UIImageOrientationRightMirrored | ||
t.tx = 0; | ||
t.ty = 0; | ||
} | ||
return t; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.