| 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 [DartPackage="mojo_services"] |
| 6 module mojo.media; | 6 module mojo.media; |
| 7 | 7 |
| 8 import "mojo/services/media/common/interfaces/media_common.mojom"; | 8 import "mojo/services/media/common/interfaces/media_common.mojom"; |
| 9 import "mojo/services/media/common/interfaces/media_types.mojom"; | 9 import "mojo/services/media/common/interfaces/media_types.mojom"; |
| 10 | 10 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 MediaPacketRegion payload; | 52 MediaPacketRegion payload; |
| 53 array<MediaPacketRegion>? extra_payload; | 53 array<MediaPacketRegion>? extra_payload; |
| 54 | 54 |
| 55 // TODO(johngro): do we need to describe the MediaType of this payload, or is | 55 // TODO(johngro): do we need to describe the MediaType of this payload, or is |
| 56 // its type implicit based on the channel over which it is being pushed? | 56 // its type implicit based on the channel over which it is being pushed? |
| 57 | 57 |
| 58 // TODO(johngro): how do we attach per-packet media specific metadata to this | 58 // TODO(johngro): how do we attach per-packet media specific metadata to this |
| 59 // packet? | 59 // packet? |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 // Models a stream producer. A MediaProducer allows a client to connect the | 62 // Models a stream producer. A MediaPacketProducer allows a client to connect |
| 63 // producer to a MediaConsumer so packets flow from the producer to the | 63 // the producer to a MediaPacketConsumer so packets flow from the producer to |
| 64 // consumer. Clients who want to receive packets directly from the producer | 64 // the consumer. Clients who want to receive packets directly from the producer |
| 65 // should use MediaPullModeProducer instead. | 65 // should use MediaPullModeProducer instead. |
| 66 // | 66 // |
| 67 // The client calls Connect to connect producer and consumer. The producer then | 67 // The client calls Connect to connect producer and consumer. The producer then |
| 68 // calls PushPacket on the consumer to deliver packets. | 68 // calls PushPacket on the consumer to deliver packets. |
| 69 interface MediaProducer { | 69 interface MediaPacketProducer { |
| 70 // Connects this MediaProducer to a MediaConsumer. | 70 // Connects this MediaPacketProducer to a MediaPacketConsumer. |
| 71 Connect(MediaConsumer consumer) => (); | 71 Connect(MediaPacketConsumer consumer) => (); |
| 72 | 72 |
| 73 // Disconnects this MediaProducer from a previously-connected MediaConsumer. | 73 // Disconnects this MediaPacketProducer from a previously-connected |
| 74 // MediaPacketConsumer. |
| 74 Disconnect(); | 75 Disconnect(); |
| 75 }; | 76 }; |
| 76 | 77 |
| 77 // Models a stream producer. A MediaPullModeProducer allows a client to receive | 78 // Models a stream consumer. A MediaPacketConsumer allows a client to send |
| 78 // packets directly from the producer. Clients who want to connect the producer | 79 // packets directly to the consumer or to connect the consumer to a |
| 79 // to a MediaConsumer should use MediaProducer instead. | 80 // MediaPacketProducer so packets flow from the producer to the consumer. |
| 80 // | |
| 81 // The client calls PullPacket to get a packet. Once the client is done with | |
| 82 // the packet, it calls ReleasePacket to let the producer know that the packet | |
| 83 // buffer region can be reused. Alternatively, the client can piggyback a | |
| 84 // release on a PullPacket call using the to_release parameter. | |
| 85 interface MediaPullModeProducer { | |
| 86 // Gets the shared buffer in which packet payload will be located. | |
| 87 GetBuffer() => (handle<shared_buffer> buffer); | |
| 88 | |
| 89 // Pulls a packet from the producer. When the client is done with the | |
| 90 // packet buffer region, it should call ReleasePacket or PullPacket passing | |
| 91 // the locator. Note that the optional locator passed in PullPacket is | |
| 92 // a locator to be released and probably won't be the same locator passed | |
| 93 // back in the callback. | |
| 94 PullPacket(MediaPacket? to_release) => (MediaPacket packet); | |
| 95 | |
| 96 // Signals the producer that the client is done with the buffer region. | |
| 97 ReleasePacket(MediaPacket to_release); | |
| 98 }; | |
| 99 | |
| 100 // Models a stream consumer. A MediaConsumer allows a client to send packets | |
| 101 // directly to the consumer or to connect the consumer to a MediaProducer so | |
| 102 // packets flow from the producer to the consumer. | |
| 103 // | 81 // |
| 104 // In the former scenario, the client calls PushPacket to deliver a packet. The | 82 // In the former scenario, the client calls PushPacket to deliver a packet. The |
| 105 // callback notifies the client that the consumer is done with the packet | 83 // callback notifies the client that the consumer is done with the packet |
| 106 // buffer region. | 84 // buffer region. |
| 107 // | 85 // |
| 108 // In the latter scenario, the client calls Connect on the producer to connect | 86 // In the latter scenario, the client calls Connect on the producer to connect |
| 109 // producer and consumer. The producer then calls PushPacket on the consumer to | 87 // producer and consumer. The producer then calls PushPacket on the consumer to |
| 110 // deliver packets. | 88 // deliver packets. |
| 111 interface MediaConsumer { | 89 interface MediaPacketConsumer { |
| 112 const uint64 kMaxBufferLen = 0x3FFFFFFFFFFFFFFF; | 90 const uint64 kMaxBufferLen = 0x3FFFFFFFFFFFFFFF; |
| 113 | 91 |
| 114 // An enumeration used to indicate the ultimate fate of packets sent across | 92 // An enumeration used to indicate the ultimate fate of packets sent across |
| 115 // the pipe using the SendPacket method. | 93 // the pipe using the SendPacket method. |
| 116 enum SendResult { | 94 enum SendResult { |
| 117 CONSUMED, // Media was completely consumed. | 95 CONSUMED, // Media was completely consumed. |
| 118 FLUSHED, // Some or all of the media was flushed before being consumed. | 96 FLUSHED, // Some or all of the media was flushed before being consumed. |
| 119 }; | 97 }; |
| 120 | 98 |
| 121 // Sets the shared buffer in which packet payload will be located. | 99 // Sets the shared buffer in which packet payload will be located. |
| 122 SetBuffer(handle<shared_buffer> buffer) => (); | 100 SetBuffer(handle<shared_buffer> buffer) => (); |
| 123 | 101 |
| 124 // Sends a packet to the consumer. The callback signals that the consumer | 102 // Sends a packet to the consumer. The callback signals that the consumer |
| 125 // is done with the packet buffer region. | 103 // is done with the packet buffer region. |
| 126 SendPacket(MediaPacket packet) => (SendResult result); | 104 SendPacket(MediaPacket packet) => (SendResult result); |
| 127 | 105 |
| 128 // Primes the stream. The callback signals that the prime operation is | 106 // Primes the stream. The callback signals that the prime operation is |
| 129 // complete. | 107 // complete. |
| 130 Prime() => (); | 108 Prime() => (); |
| 131 | 109 |
| 132 // Flushes the stream. The callback signals that the flush operation is | 110 // Flushes the stream. The callback signals that the flush operation is |
| 133 // complete. | 111 // complete. |
| 134 Flush() => (); | 112 Flush() => (); |
| 135 }; | 113 }; |
| OLD | NEW |