| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The Chromium 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 [DartPackage="mojo_services"] | |
| 6 module mojo.media; | |
| 7 | |
| 8 // TimelineQuad | |
| 9 // TODO(dalesat): Rename reference -> presentation. | |
| 10 // TODO(dalesat): Rename target -> reference. | |
| 11 // | |
| 12 // A structure which holds the four numbers needed to define a linear | |
| 13 // relationship between the points in two different timelines. The relationship | |
| 14 // is expressed using 4 integers in order to facilitate compositions of multiple | |
| 15 // transformations (A->B can be composed with B->C to produce the transformation | |
| 16 // from A->C), and to minimize rounding and scaling errors when mapping points | |
| 17 // between timelines which do not have an integer scaling relationship between | |
| 18 // each other. | |
| 19 // | |
| 20 // These values are used to define the following functions which map from | |
| 21 // points from the reference timeline to the target timeline, and back again. | |
| 22 // | |
| 23 // Let r be a point in the reference timeline. | |
| 24 // Let t be a point in the target timeline timeline. | |
| 25 // Let ref and tgt be abbreviations for reference and target in equations below. | |
| 26 // | |
| 27 // Given that r and t represent the same instant in time (in a single frame of | |
| 28 // reference) | |
| 29 // | |
| 30 // t = f(r) = (((r - ref_offset) * tgt_delta) / ref_delta) + tgt_offset | |
| 31 // r = F(t) = (((t - tgt_offset) * ref_delta) / tgt_delta) + ref_offset | |
| 32 // | |
| 33 // See also... | |
| 34 // mojo/services/media/common/linear_transform.h | |
| 35 // | |
| 36 // no-format | |
| 37 struct TimelineQuad { | |
| 38 int64 reference_offset = 0; | |
| 39 int64 target_offset = 0; | |
| 40 uint32 reference_delta = 0; | |
| 41 uint32 target_delta = 1; | |
| 42 }; | |
| 43 // end-no-format | |
| 44 | |
| 45 // TimelineTransform | |
| 46 // TODO(dalesat): Rename reference -> presentation. | |
| 47 // TODO(dalesat): Rename target -> reference. | |
| 48 // | |
| 49 // A structure which holds both a timeline quad, and a pair of identifiers which | |
| 50 // define the specific timelines which are the reference and target timelines. | |
| 51 struct TimelineTransform { | |
| 52 // TODO: These constants should probably defined by a central time management | |
| 53 // service, not here. | |
| 54 const uint32 kLocalTimeID = 0xFFFFFFFF; | |
| 55 const uint32 kContextual = 0xFFFFFFFE; | |
| 56 | |
| 57 TimelineQuad quad; | |
| 58 uint32 reference_timeline_id = kContextual; | |
| 59 uint32 target_timeline_id = kLocalTimeID; | |
| 60 }; | |
| 61 | |
| 62 // RateControl | |
| 63 // | |
| 64 // An interface typically exposed by media renderers which allow producers of | |
| 65 // media to specify how the presentation time stamps of the media queued to the | |
| 66 // renderer relate to real time. Users may initialize the transformation with a | |
| 67 // specific Quad, change the rate immediately in a first order contiguous | |
| 68 // fashion, or schedule ranges in the rate at points in time on either the | |
| 69 // reference or target timelines. | |
| 70 interface RateControl { | |
| 71 // Get the current quad which describes the transformation between the | |
| 72 // reference and target timelines. | |
| 73 GetCurrentTransform() => (TimelineTransform trans); | |
| 74 | |
| 75 // Immediately, explicitly set the quad which describes the mapping from | |
| 76 // reference to target timeline. It is understood that this can cause | |
| 77 // discontinuities and should only be used in situations which are already | |
| 78 // fundamentally discontinuous (startup/seeking, for example) | |
| 79 SetCurrentQuad(TimelineQuad quad); | |
| 80 | |
| 81 // Configure the target timeline ID. Note, the reference timeline ID will | |
| 82 // always be contextual. | |
| 83 SetTargetTimelineID(uint32 id); | |
| 84 | |
| 85 // Immediately change the rate of the existing transformation in a fashion | |
| 86 // which is first order continuous with the current transformation. | |
| 87 SetRate(uint32 reference_delta, uint32 target_delta); | |
| 88 | |
| 89 // Schedule a first order continuous rate change at the specified reference | |
| 90 // time. | |
| 91 SetRateAtReferenceTime(uint32 reference_delta, | |
| 92 uint32 target_delta, | |
| 93 int64 reference_time); | |
| 94 | |
| 95 // Schedule a first order continuous rate change at the specified target time. | |
| 96 SetRateAtTargetTime(uint32 reference_delta, | |
| 97 uint32 target_delta, | |
| 98 int64 target_time); | |
| 99 | |
| 100 // Cancel any pending rate changes | |
| 101 CancelPendingChanges(); | |
| 102 }; | |
| OLD | NEW |