[video_player_avfoundation] enable more than 30 fps (#7466)

In the player there was hardcoded 30 fps when setting up video composition. Now it uses timing from source track and also fallback `minFrameDuration` as seems `frameDuration` must be always set to something and it takes over in some situations as is mentioned in documentation about `sourceTrackIDForFrameTiming`. Also video composition setup is skipped when it is not needed when `preferredTransform` is identity.

Function `updatePlayingState` is called often right after `setupEventSinkIfReadyToPlay` but seems it was forgotten in `onListenWithArguments` and also it cannot be called in that way because `setupEventSinkIfReadyToPlay` may finish asynchronously when called again from line `[self performSelector:_cmd onThread:NSThread.mainThread withObject:self waitUntilDone:NO]` so now is `updatePlayingState` called right after `_isInitialized = YES` which is what it needs to even do something.

There was one more obstacle for playing 60 fps videos on 60 hz screen. Seems there are at least two "display links" at play when playing video, one calls function `displayLinkFired` and other one from flutter engine calls `copyPixelBuffer` but only when `textureFrameAvailable` was called previously. But the order in which those two are called is undefined so 16 ms after `displayLinkFired` may be called `copyPixelBuffer` and right after that `displayLinkFired` and so on. But `copyPixelBuffer` steals the newest pixel buffer from video player output and in `displayLinkFired` `hasNewPixelBufferForItemTime` will not report another pixel buffer for time close to that. Then the next frame is not called `copyPixelBuffer` because `textureFrameAvailable` was not called and in this way it skips every second frame so it plays video at 30 fps. There was also a synchronization problem with `lastKnownAvailableTime`. Now pixel buffers are produced and reported just on a single place in `displayLinkFired` and received with correct synchronization in `copyPixelBuffer`. Ideally there would be just a single "display link" from flutter engine if it supported also pulling frames instead of only pushing (which is good enough for a camera where the system is pushing frames to us, but from player video output is needed to pull frames). Calling `textureFrameAvailable` every frame could accomplish that but it looks like this line in flutter engine is calling even when `copyPixelBuffer` returns NULL and it may be expensive (although there is no need to call it in such case):

```
sk_sp<flutter::DlImage> image = [self wrapExternalPixelBuffer:_lastPixelBuffer context:context];
```

Seems there is some bug with the video player using this flutter engine on macos. Looks like the video is playing normally but then it starts "tearing", it looks like it is displaying frames normally but once in a while it shows some frame from the past like some previously cached frame. This is happening on the main branch but rendering on 60 fps exaggerates it (it is not caused by this PR).
10 files changed
tree: 0b7b278d7b75557420b8910b182da5445f1608e1
  1. .ci/
  2. .github/
  3. packages/
  4. script/
  5. third_party/
  6. .ci.yaml
  7. .clang-format
  8. .gitattributes
  9. .gitignore
  10. .metadata
  11. analysis_options.yaml
  12. AUTHORS
  13. CODEOWNERS
  14. CONTRIBUTING.md
  15. customer_testing.bat
  16. customer_testing.sh
  17. LICENSE
  18. README.md
README.md

Flutter Packages

Release Status Flutter CI Status

This repo is a companion repo to the main flutter repo. It contains the source code for Flutter's first-party packages (i.e., packages developed by the core Flutter team). Check the packages directory to see all packages.

These packages are also available on pub.

Issues

Please file any issues, bugs, or feature requests in the main flutter repo. Issues pertaining to this repository are labeled “package”.

Contributing

If you wish to contribute a new package to the Flutter ecosystem, please see the documentation for developing packages. You can store your package source code in any GitHub repository (the present repo is only intended for packages developed by the core Flutter team). Once your package is ready you can publish to the pub repository.

If you wish to contribute a change to any of the existing packages in this repo, please review our contribution guide, and send a pull request.

Packages

These are the packages hosted in this repository:

PackagePubPointsPopularityIssuesPull requests
animationspub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
camerapub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
cross_filepub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
css_colorspub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
cupertino_iconspub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
espressopub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
extension_google_sign_in_as_googleapis_authpub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
file_selectorpub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
flutter_adaptive_scaffoldpub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
flutter_imagepub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
flutter_lintspub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
flutter_markdownpub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
flutter_plugin_android_lifecyclepub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
flutter_svgpub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
flutter_svg_testpub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
flutter_template_imagespub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
go_routerpub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
go_router_builderpub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
google_adsensepub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
google_maps_flutterpub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
google_sign_inpub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
image_pickerpub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
interactive_media_adspub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
in_app_purchasepub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
ios_platform_imagespub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
local_authpub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
metrics_centerpub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
multicast_dnspub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
palette_generatorpub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
path_parsingpub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
path_providerpub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
pigeonpub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
pointer_interceptorpub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
plugin_platform_interfacepub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
processpub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
quick_actionspub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
google_identity_services_webpub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
rfwpub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
shared_preferencespub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
standard_message_codecpub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
two_dimensional_scrollablespub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
url_launcherpub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
vector_graphicspub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
vector_graphics_codecpub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
vector_graphics_compilerpub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
video_playerpub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
web_benchmarkspub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
webview_flutterpub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label
xdg_directoriespub packagepub pointspopularityGitHub issues by-labelGitHub pull requests by-label