Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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 module media.mojom; | |
| 6 | |
| 7 interface RemoterFactory { | |
| 8 // Create a new Remoter associated with the given RemotingSource and bind it | |
| 9 // to the given interface request. The RemotingSource will be notified when | |
| 10 // the Remoter becomes available for use (or becomes unavailable). | |
| 11 Create(RemotingSource source, Remoter& remoter); | |
| 12 }; | |
| 13 | |
| 14 // Interface used by the source to control when media bitstream data is read | |
| 15 // from the data pipes and then sent to the remote endpoint. | |
| 16 interface RemotingDataStreamSender { | |
| 17 // Consumes |size| bytes of data from the data pipe, which is a chunk of the | |
|
Ken Rockot(use gerrit already)
2016/09/12 15:26:05
doc nit: From which data pipe?
miu
2016/09/14 23:55:30
The one and only. ;-)
So, my comments for the who
| |
| 18 // next frame's data payload starting at the given byte |offset|. | |
| 19 // |total_payload_size| indicates the size of the entire data payload for the | |
| 20 // frame. Before this is called, |size| bytes of data must have been written | |
| 21 // into the data pipe. | |
| 22 // | |
| 23 // Normally, a frame's entire data payload can be pushed through the data pipe | |
| 24 // in one chunk. However, there can be situations where the size of the | |
| 25 // payload exceeds the capacity of the data pipe; and so this API supports | |
| 26 // feeding the frame data through the pipe in multiple chunks. | |
| 27 ConsumeDataChunk(uint32 offset, uint32 size, uint32 total_payload_size); | |
| 28 | |
| 29 // Enqueues another frame for transmission to the remote endpoint. Before this | |
| 30 // is called, ConsumeDataChunk() must have been called one or more times to | |
| 31 // provide all of the frame's data. | |
| 32 SendFrame(); | |
| 33 | |
| 34 // Cancel the transmission of all in-flight data to the remote, up to and | |
| 35 // including the last SendFrame() call; and also discard any data chunks | |
|
Ken Rockot(use gerrit already)
2016/09/12 15:26:05
doc nit: Is this an accurate guarantee? Can't a ca
miu
2016/09/14 23:55:30
Yes. Cancel in this context means "I decided not t
| |
| 36 // that were consumed from the data pipe for the next frame. This is used to | |
| 37 // optimize seeking, when it is known that any in-flight data is no longer | |
| 38 // needed by the remote. | |
| 39 CancelInFlightData(); | |
| 40 }; | |
| 41 | |
| 42 enum RemotingStopReason { | |
| 43 ROUTE_TERMINATED, // User-initiated disconnect, etc. | |
| 44 LOCAL_PLAYBACK, // Media switched back to local playback. | |
| 45 SOURCE_GONE, // RemotingSource has been destroyed. | |
| 46 MESSAGE_SEND_FAILED, // Failed to send a message to the sink. | |
| 47 DATA_SEND_FAILED, // Failed to consume from a data pipe or send to the sink. | |
| 48 UNEXPECTED_FAILURE, // Unexpected failure or inconsistent state encountered. | |
| 49 }; | |
| 50 | |
| 51 // Interface used by the source to start/stop remoting and send data to the | |
| 52 // sink. | |
| 53 interface Remoter { | |
| 54 // Start a remoting session (once the sink has been reported to be available; | |
| 55 // see RemotingSource). Either RemotingSource.OnStarted() or OnStartFailed() | |
| 56 // will be called to indicate success or failure. Once OnStarted() has been | |
| 57 // invoked, the source may then make calls to SendMessageToSink() and expect | |
| 58 // messages from the remote via RemotingSource.OnMessageFromSink(). | |
| 59 Start(); | |
| 60 | |
| 61 // Start remoting the media data streams. This is called after Start() to | |
| 62 // provide data pipes from which the audio/video bitstream data is consumed | |
| 63 // and then transported to the remote device. RemotingDataStreamSenders are | |
| 64 // used by the source to control when data should be consumed from the data | |
| 65 // pipes and sent. One or both pipes (and their corresponding | |
| 66 // RemotingDataStreamSender interface requests) must be provided. | |
| 67 StartDataStreams(handle<data_pipe_consumer>? audio_pipe, | |
| 68 handle<data_pipe_consumer>? video_pipe, | |
| 69 RemotingDataStreamSender&? audio_sender, | |
| 70 RemotingDataStreamSender&? video_sender); | |
| 71 | |
| 72 // Stop remoting media. Messages in both directions will be dropped after this | |
| 73 // point as well as any pending or in-transit media bitstream data. | |
| 74 Stop(RemotingStopReason reason); | |
| 75 | |
| 76 // Send |message| to the sink. |message| is a serialized protobuf from | |
| 77 // src/media/remoting/proto. | |
| 78 SendMessageToSink(array<uint8> message); | |
| 79 }; | |
| 80 | |
| 81 enum RemotingStartFailReason { | |
| 82 CANNOT_START_MULTIPLE, // Remoting was already active. | |
| 83 ROUTE_TERMINATED, // User-initated disconnect while starting remoting. | |
| 84 }; | |
| 85 | |
| 86 // Interface used for sending notifications back to the local source's control | |
| 87 // logic, and to pass messages from the sink back to the local media pipeline. | |
| 88 interface RemotingSource { | |
| 89 // Notify the source that the sink is now available to start remoting. It is | |
| 90 // up to the source's control logic to decide whether/when to start remoting. | |
| 91 // | |
| 92 // TODO(miu): In a later change, also pass information about the sink's | |
| 93 // capabilities (e.g., codec support, DRM keysystem support, etc.). | |
| 94 OnSinkAvailable(); | |
| 95 | |
| 96 // Notify the source that the sink is no longer available for remoting. This | |
| 97 // may happen, for example, because the sink has been shut down, or because | |
| 98 // another source has started remoting. | |
| 99 OnSinkGone(); | |
| 100 | |
| 101 // One of these is called after the source attempts to start remoting. If | |
| 102 // OnStarted() is called, messages may begin flowing; and this will continue | |
| 103 // until OnStopped() is called. On the other hand, if OnStartFailed() is | |
| 104 // called, then no messages are being passed between source and sink and | |
| 105 // remoting is not taking place. | |
| 106 OnStarted(); | |
| 107 OnStartFailed(RemotingStartFailReason reason); | |
| 108 | |
| 109 // Pass a |message| from the sink back to the source. The |message| consists | |
| 110 // of a serialized protobuf from src/media/remoting/proto. This will only be | |
| 111 // called after OnStarted() and before OnStopped(). | |
| 112 OnMessageFromSink(array<uint8> message); | |
| 113 | |
| 114 // Notify the source that remoting has terminated. This may or may not be in | |
| 115 // response to a Remoter.Stop() call, as other events (possibly external) may | |
| 116 // have caused remoting to end. | |
| 117 OnStopped(RemotingStopReason reason); | |
| 118 }; | |
| OLD | NEW |