Flutter macOS Embedder
FlutterTimeConverter.mm
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTER_TIME_CONVERTER_MM_
6 #define FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTER_TIME_CONVERTER_MM_
7 
10 
11 @interface FlutterTimeConverter () {
13 }
14 @end
15 
16 @implementation FlutterTimeConverter
17 
18 - (instancetype)initWithEngine:(FlutterEngine*)engine {
19  self = [super init];
20  if (self) {
21  _engine = engine;
22  }
23  return self;
24 }
25 
26 - (uint64_t)CAMediaTimeToEngineTime:(CFTimeInterval)time {
27  FlutterEngine* engine = _engine;
28  if (!engine) {
29  return 0;
30  }
31  return (time - CACurrentMediaTime()) * NSEC_PER_SEC + engine.embedderAPI.GetCurrentTime();
32 }
33 
34 - (CFTimeInterval)engineTimeToCAMediaTime:(uint64_t)time {
35  FlutterEngine* engine = _engine;
36  if (!engine) {
37  return 0;
38  }
39  return (static_cast<int64_t>(time) - static_cast<int64_t>(engine.embedderAPI.GetCurrentTime())) /
40  static_cast<double>(NSEC_PER_SEC) +
41  CACurrentMediaTime();
42 }
43 
44 @end
45 
46 #endif // FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTER_TIME_CONVERTER_MM_-
FlutterEngine
Definition: FlutterEngine.h:30
FlutterTimeConverter.h
FlutterEngine_Internal.h
FlutterTimeConverter
Converts between the time representation used by Flutter Engine and CAMediaTime.
Definition: FlutterTimeConverter.h:13
FlutterTimeConverter()::_engine
__weak FlutterEngine * _engine
Definition: FlutterTimeConverter.mm:12