| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 [DartPackage="mojo_services"] |
| 5 module mojo.media; | 6 module mojo.media; |
| 6 | 7 |
| 7 import "mojo/services/media/common/interfaces/media_common.mojom"; | 8 import "mojo/services/media/common/interfaces/media_common.mojom"; |
| 8 | 9 |
| 9 // MediaPacketRegion | 10 // MediaPacketRegion |
| 10 // | 11 // |
| 11 // A small structure used to keep track of a portion of a shared buffer used by | 12 // A small structure used to keep track of a portion of a shared buffer used by |
| 12 // a MediaPacket to hold its payload. | 13 // a MediaPacket to hold its payload. |
| 13 struct MediaPacketRegion { | 14 struct MediaPacketRegion { |
| 14 uint64 offset; | 15 uint64 offset; |
| 15 uint64 length; | 16 uint64 length; |
| 16 }; | 17 }; |
| 17 | 18 |
| 18 // MediaPacket | 19 // MediaPacket |
| 19 // | 20 // |
| 20 // A structure which hold the definition of an atomic unit of media which may be | 21 // A structure which hold the definition of an atomic unit of media which may be |
| 21 // sent across a media pipe. MediaPackets consist of the metadata for the unit | 22 // sent across a media pipe. MediaPackets consist of the metadata for the unit |
| 22 // of media, as well as the set of offset/lengths in the pipe's shared buffer | 23 // of media, as well as the set of offset/lengths in the pipe's shared buffer |
| 23 // which define the payload of the packet itself. | 24 // which define the payload of the packet itself. |
| 24 struct MediaPacket { | 25 struct MediaPacket { |
| 25 const int64 kNoTimestamp = 0x7fffffffffffffff; | 26 const int64 kNoTimestamp = 0x7fffffffffffffff; |
| 26 | 27 |
| 27 // Presentation Time Stamp. Time time at which the media should be presented, | 28 // Presentation Time Stamp. Time at which the media should be presented, |
| 28 // according to the media timeline. | 29 // according to the media timeline. |
| 29 int64 pts = kNoTimestamp; | 30 int64 pts = kNoTimestamp; |
| 30 | 31 |
| 32 // Duration represented by the packet. |
| 33 uint64 duration; |
| 34 |
| 35 // Indicates whether this is the last packet in the stream. |
| 36 bool end_of_stream; |
| 37 |
| 31 // Bookkeeping to determine where this MediaPacket's payload exists in its | 38 // Bookkeeping to determine where this MediaPacket's payload exists in its |
| 32 // MediaPipe's shared buffer. | 39 // MediaPipe's shared buffer. |
| 33 // | 40 // |
| 34 // For simple cases, only the payload field is used. It provides the offset | 41 // For simple cases, only the payload field is used. It provides the offset |
| 35 // into the shared buffer for the payload, as well as its length. In more | 42 // into the shared buffer for the payload, as well as its length. In more |
| 36 // complicated cases (circular buffer, arbitrary scatter-gather), additional | 43 // complicated cases (circular buffer, arbitrary scatter-gather), additional |
| 37 // regions may be described in the extra_payload array. Logically, the | 44 // regions may be described in the extra_payload array. Logically, the |
| 38 // payload is the concatination of the payload region, followed by the extra | 45 // payload is the concatination of the payload region, followed by the extra |
| 39 // payload regions, from index 0 to index N-1. | 46 // payload regions, from index 0 to index N-1. |
| 40 // | 47 // |
| 41 // TODO(johngro): Depending on what happens with mojo struct marshalling, | 48 // TODO(johngro): Depending on what happens with mojo struct marshalling, |
| 42 // consider merging payload and extra_payload into just a single array. The | 49 // consider merging payload and extra_payload into just a single array. The |
| 43 // intention was to not need any extra allocations if there way only a single | 50 // intention was to not need any extra allocations if there way only a single |
| 44 // payload region, but right now we always need to allocate an array, even if | 51 // payload region, but right now we always need to allocate an array, even if |
| 45 // it is zero length. If this is not going to change, then we should just | 52 // it is zero length. If this is not going to change, then we should just |
| 46 // merge these two fields. | 53 // merge these two fields. |
| 47 MediaPacketRegion payload; | 54 MediaPacketRegion payload; |
| 48 array<MediaPacketRegion> extra_payload; | 55 array<MediaPacketRegion>? extra_payload; |
| 49 | 56 |
| 50 // TODO(johngro): do we need to describe the MediaType of this payload, or is | 57 // TODO(johngro): do we need to describe the MediaType of this payload, or is |
| 51 // its type implicit based on the channel over which it is being pushed? | 58 // its type implicit based on the channel over which it is being pushed? |
| 52 | 59 |
| 53 // TODO(johngro): how do we attach per-packet media specific metadata to this | 60 // TODO(johngro): how do we attach per-packet media specific metadata to this |
| 54 // packet? | 61 // packet? |
| 55 }; | 62 }; |
| 56 | 63 |
| 57 // MediaPipeState | 64 // MediaPipeState |
| 58 // | 65 // |
| (...skipping 27 matching lines...) Expand all Loading... |
| 86 // Request that a reference to the pipe's state be sent to the caller via | 93 // Request that a reference to the pipe's state be sent to the caller via |
| 87 // callback. | 94 // callback. |
| 88 GetState() => (MediaPipeState state); | 95 GetState() => (MediaPipeState state); |
| 89 | 96 |
| 90 // Place a media packet into the pipeline to be consumed. When the consumer | 97 // Place a media packet into the pipeline to be consumed. When the consumer |
| 91 // is finished with the packet, it will invoke the supplied callback to | 98 // is finished with the packet, it will invoke the supplied callback to |
| 92 // indicate that the region of the shared buffer indicated by the MediaPacket | 99 // indicate that the region of the shared buffer indicated by the MediaPacket |
| 93 // object is now available for new data. MediaResults in the operation may | 100 // object is now available for new data. MediaResults in the operation may |
| 94 // include... | 101 // include... |
| 95 // | 102 // |
| 96 // kOK: | 103 // OK: |
| 97 // Media packet has been consumed without error. | 104 // Media packet has been consumed without error. |
| 98 // kBadState: | 105 // BAD_STATE: |
| 99 // The media pipe is in a bad state (perhaps uninitialized) and payloads | 106 // The media pipe is in a bad state (perhaps uninitialized) and payloads |
| 100 // cannot be pushed to it. | 107 // cannot be pushed to it. |
| 101 // kInvalidArgs: | 108 // INVALID_ARGUMENT: |
| 102 // One or more of the payload regions does not appears to go outside the | 109 // One or more of the payload regions does not appears to go outside the |
| 103 // shared buffer bounds. | 110 // shared buffer bounds. |
| 104 // kFlushed: | 111 // FLUSHED: |
| 105 // The packet was flushed at the request of the producer. It was not | 112 // The packet was flushed at the request of the producer. It was not |
| 106 // completely consumed (but may have been partially consumed) | 113 // completely consumed (but may have been partially consumed) |
| 107 SendPacket(MediaPacket packet) => (MediaResult result); | 114 SendPacket(MediaPacket packet) => (MediaResult result); |
| 108 | 115 |
| 109 // Flush the pipe, discarding all queued packets in order (from front to back) | 116 // Flush the pipe, discarding all queued packets in order (from front to back) |
| 110 // as we go. When the flush operation is complete, the provided callback will | 117 // as we go. When the flush operation is complete, the provided callback will |
| 111 // be invoked to indicate that the consumer end of the pipe has finished | 118 // be invoked to indicate that the consumer end of the pipe has finished |
| 112 // flushing and that the pipeline is now empty. Possible values for the | 119 // flushing and that the pipeline is now empty. Possible values for the |
| 113 // MediaResult parameter of the callback include... | 120 // MediaResult parameter of the callback include... |
| 114 // | 121 // |
| 115 // kOK: | 122 // OK: |
| 116 // Pipeline has been successfully flushed. | 123 // Pipeline has been successfully flushed. |
| 117 // kBusy: | 124 // BUSY: |
| 118 // A flush was already in progress, this flush request was ignored. | 125 // A flush was already in progress, this flush request was ignored. |
| 119 // kBadState: | 126 // BAD_STATE: |
| 120 // The media pipe is in a bad state (perhaps uninitialized) and cannot be | 127 // The media pipe is in a bad state (perhaps uninitialized) and cannot be |
| 121 // flushed | 128 // flushed |
| 122 Flush() => (MediaResult result); | 129 Flush() => (MediaResult result); |
| 123 }; | 130 }; |
| OLD | NEW |