OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 module media.mojom; | 5 module media.mojom; |
6 | 6 |
7 interface RemoterFactory { | 7 import "media/mojo/interfaces/remoting_common.mojom"; |
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 a data pipe and then sent to the remote endpoint. There is one | |
16 // RemotingDataStreamSender per data pipe. | |
17 interface RemotingDataStreamSender { | |
18 // Consumes |size| bytes of data from the data pipe, which is a chunk of the | |
19 // next frame's data payload starting at the given byte |offset|. | |
20 // |total_payload_size| indicates the size of the entire data payload for the | |
21 // frame. Before this is called, |size| bytes of data must have been written | |
22 // into the data pipe. | |
23 // | |
24 // Normally, a frame's entire data payload can be pushed through the data pipe | |
25 // in one chunk. However, there can be situations where the size of the | |
26 // payload exceeds the capacity of the data pipe; and so this API supports | |
27 // feeding the frame data through the pipe in multiple chunks. | |
28 ConsumeDataChunk(uint32 offset, uint32 size, uint32 total_payload_size); | |
29 | |
30 // Enqueues another frame for transmission to the remote endpoint. Before this | |
31 // is called, ConsumeDataChunk() must have been called one or more times to | |
32 // provide all of the frame's data. | |
33 SendFrame(); | |
34 | |
35 // Cancel the transmission of all in-flight data to the remote, up to and | |
36 // including the last SendFrame() call; and also discard any data chunks | |
37 // that were consumed from the data pipe for the next frame. This is used to | |
38 // optimize seeking, when it is known that any in-flight data is no longer | |
39 // needed by the remote. There is no guarantee as to how much of the in-flight | |
40 // data will actually reach the remote before the cancellation takes effect. | |
41 CancelInFlightData(); | |
42 }; | |
43 | |
44 enum RemotingStopReason { | |
45 ROUTE_TERMINATED, // User-initiated disconnect, etc. | |
46 LOCAL_PLAYBACK, // Media switched back to local playback. | |
47 SOURCE_GONE, // RemotingSource has been destroyed. | |
48 MESSAGE_SEND_FAILED, // Failed to send a message to the sink. | |
49 DATA_SEND_FAILED, // Failed to consume from a data pipe or send to the sink. | |
50 UNEXPECTED_FAILURE, // Unexpected failure or inconsistent state encountered. | |
51 }; | |
52 | 8 |
53 // Interface used by the source to start/stop remoting and send data to the | 9 // Interface used by the source to start/stop remoting and send data to the |
54 // sink. | 10 // sink. |
55 interface Remoter { | 11 interface MirrorServiceRemoter { |
56 // Start a remoting session (once the sink has been reported to be available; | 12 // Starts a remoting session. Always assumes the remoting session will be |
57 // see RemotingSource). Either RemotingSource.OnStarted() or OnStartFailed() | 13 // stared successfully. If any failure happens, |
58 // will be called to indicate success or failure. Once OnStarted() has been | 14 // MirrorServiceRemotingSource::OnError() will be called. |
59 // invoked, the source may then make calls to SendMessageToSink() and expect | |
60 // messages from the remote via RemotingSource.OnMessageFromSink(). | |
61 Start(); | 15 Start(); |
62 | 16 |
63 // Start remoting the media data streams. This is called after Start() to | 17 // Starts remoting the media data streams. This is called after Start() to |
64 // provide data pipes from which the audio/video bitstream data is consumed | 18 // indicate audio/video bitstream data is ready to be consumed. |
65 // and then transported to the remote device. RemotingDataStreamSenders are | 19 StartDataStreams(bool has_audio, bool has_video) |
66 // used by the source to control when data should be consumed from the data | 20 => (int32 audio_stream_id, int32 video_stream_id); |
imcheng
2017/07/05 18:53:09
Are the IDs returned guaranteed to be valid if the
xjz
2017/07/06 22:03:45
These IDs could be -1 when error occurred. CastRem
| |
67 // pipes and sent. One or both pipes (and their corresponding | |
68 // RemotingDataStreamSender interface requests) must be provided. | |
69 StartDataStreams(handle<data_pipe_consumer>? audio_pipe, | |
70 handle<data_pipe_consumer>? video_pipe, | |
71 RemotingDataStreamSender&? audio_sender, | |
72 RemotingDataStreamSender&? video_sender); | |
73 | 21 |
74 // Stop remoting media. Messages in both directions will be dropped after this | 22 // Stops remoting media. Messages in both directions will be dropped after |
75 // point as well as any pending or in-transit media bitstream data. | 23 // this point as well as any pending or in-transit media bitstream data. |
76 Stop(RemotingStopReason reason); | 24 Stop(RemotingStopReason reason); |
77 | 25 |
78 // Send |message| to the sink. |message| is a serialized protobuf from | 26 // Sends|message| to the sink. |message| is a serialized protobuf from |
79 // src/media/remoting/proto. | 27 // src/media/remoting/proto. |
80 SendMessageToSink(array<uint8> message); | 28 SendMessageToSink(array<uint8> message); |
81 }; | 29 }; |
82 | 30 |
83 enum RemotingSinkCapabilities { | 31 // Interface used for sending notifications back to the source's control logic, |
84 NONE, | 32 // and to pass messages from the sink back to the source. |
85 RENDERING_ONLY, | 33 interface MirrorServiceRemotingSource { |
86 CONTENT_DECRYPTION_AND_RENDERING, | 34 // Notifies the source that the sink is now available to start remoting and |
87 }; | 35 // passes the receiver's capabilities. It is up to the source's control logic |
36 // to decide whether/when to start remoting. | |
37 OnSinkAvailable(SinkCapabilities capabilities); | |
88 | 38 |
89 enum RemotingStartFailReason { | 39 // Passes a |message| from the sink back to the source. The |message| consists |
90 CANNOT_START_MULTIPLE, // Remoting was already active. | |
91 ROUTE_TERMINATED, // User-initated disconnect while starting remoting. | |
92 }; | |
93 | |
94 // Interface used for sending notifications back to the local source's control | |
95 // logic, and to pass messages from the sink back to the local media pipeline. | |
96 interface RemotingSource { | |
97 // Notify the source that the sink is now available to start remoting. It is | |
98 // up to the source's control logic to decide whether/when to start remoting. | |
99 // | |
100 // TODO(miu): In a later change, pass detailed information about the sink's | |
101 // capabilities (e.g., codec support, DRM keysystem support, etc.). | |
102 OnSinkAvailable(RemotingSinkCapabilities capabilities); | |
103 | |
104 // Notify the source that the sink is no longer available for remoting. This | |
105 // may happen, for example, because the sink has been shut down, or because | |
106 // another source has started remoting. | |
107 OnSinkGone(); | |
108 | |
109 // One of these is called after the source attempts to start remoting. If | |
110 // OnStarted() is called, messages may begin flowing; and this will continue | |
111 // until OnStopped() is called. On the other hand, if OnStartFailed() is | |
112 // called, then no messages are being passed between source and sink and | |
113 // remoting is not taking place. | |
114 OnStarted(); | |
115 OnStartFailed(RemotingStartFailReason reason); | |
116 | |
117 // Pass a |message| from the sink back to the source. The |message| consists | |
118 // of a serialized protobuf from src/media/remoting/proto. This will only be | 40 // of a serialized protobuf from src/media/remoting/proto. This will only be |
119 // called after OnStarted() and before OnStopped(). | 41 // called after OnStarted() and before OnStopped(). |
120 OnMessageFromSink(array<uint8> message); | 42 OnMessageFromSink(array<uint8> message); |
121 | 43 |
122 // Notify the source that remoting has terminated. This may or may not be in | 44 // Notifies the source that remoting has terminated. This may or may not be in |
123 // response to a Remoter.Stop() call, as other events (possibly external) may | 45 // response to a Remoter.Stop() call, as other events (possibly external) may |
124 // have caused remoting to end. | 46 // have caused remoting to end. |
125 OnStopped(RemotingStopReason reason); | 47 OnStopped(RemotingStopReason reason); |
48 | |
49 // Notifies the source that a fatal error has occurred. Remoting session will | |
50 // be stopped immediately once this is called. | |
51 OnError(); | |
126 }; | 52 }; |
OLD | NEW |