| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_MEDIA_CAST_REMOTING_CONNECTOR_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_CAST_REMOTING_CONNECTOR_H_ |
| 6 #define CHROME_BROWSER_MEDIA_CAST_REMOTING_CONNECTOR_H_ | 6 #define CHROME_BROWSER_MEDIA_CAST_REMOTING_CONNECTOR_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/supports_user_data.h" | 11 #include "base/supports_user_data.h" |
| 12 #include "chrome/browser/media/router/media_routes_observer.h" | 12 #include "chrome/browser/media/router/media_routes_observer.h" |
| 13 #include "chrome/common/media_router/route_message.h" | |
| 14 #include "media/mojo/interfaces/remoting.mojom.h" | 13 #include "media/mojo/interfaces/remoting.mojom.h" |
| 15 | 14 |
| 16 namespace content { | 15 namespace content { |
| 17 class RenderFrameHost; | 16 class RenderFrameHost; |
| 18 class WebContents; | 17 class WebContents; |
| 18 struct PresentationConnectionMessage; |
| 19 } | 19 } |
| 20 | 20 |
| 21 // CastRemotingConnector connects a single source (a media element in a render | 21 // CastRemotingConnector connects a single source (a media element in a render |
| 22 // frame) with a single sink (a media player in a remote device). There is one | 22 // frame) with a single sink (a media player in a remote device). There is one |
| 23 // instance of a CastRemotingConnector per source WebContents (representing a | 23 // instance of a CastRemotingConnector per source WebContents (representing a |
| 24 // collection of render frames), and it is created on-demand. The source in the | 24 // collection of render frames), and it is created on-demand. The source in the |
| 25 // render process represents itself by providing a media::mojom::RemotingSource | 25 // render process represents itself by providing a media::mojom::RemotingSource |
| 26 // service instance. The sink is represented by the Media Router Cast Provider. | 26 // service instance. The sink is represented by the Media Router Cast Provider. |
| 27 // | 27 // |
| 28 // Whenever a candidate media source is created in a render frame, | 28 // Whenever a candidate media source is created in a render frame, |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 void StopRemoting(RemotingBridge* bridge, | 127 void StopRemoting(RemotingBridge* bridge, |
| 128 media::mojom::RemotingStopReason reason); | 128 media::mojom::RemotingStopReason reason); |
| 129 void SendMessageToSink(RemotingBridge* bridge, | 129 void SendMessageToSink(RemotingBridge* bridge, |
| 130 const std::vector<uint8_t>& message); | 130 const std::vector<uint8_t>& message); |
| 131 | 131 |
| 132 // Send a control message to the Cast Provider. This may or may not succeed, | 132 // Send a control message to the Cast Provider. This may or may not succeed, |
| 133 // with the success status reported later via HandleSendMessageResult(). | 133 // with the success status reported later via HandleSendMessageResult(). |
| 134 void SendMessageToProvider(const std::string& message); | 134 void SendMessageToProvider(const std::string& message); |
| 135 | 135 |
| 136 // Called by the current MessageObserver to process messages observed on the | 136 // Called by the current MessageObserver to process messages observed on the |
| 137 // remoting route. There are two types of messages: 1) TEXT notification | 137 // remoting route. There are two types of messages: 1) text notification |
| 138 // messages from the Cast Provider, to report on the current state of a | 138 // messages from the Cast Provider, to report on the current state of a |
| 139 // remoting session between Chrome and the remote device, and 2) BINARY | 139 // remoting session between Chrome and the remote device, and 2) binary |
| 140 // messages, to be passed directly to the active remoting source during a | 140 // messages, to be passed directly to the active remoting source during a |
| 141 // remoting session. | 141 // remoting session. |
| 142 void ProcessMessagesFromRoute( | 142 void ProcessMessagesFromRoute( |
| 143 const std::vector<media_router::RouteMessage>& messages); | 143 const std::vector<content::PresentationConnectionMessage>& messages); |
| 144 | 144 |
| 145 // Error handlers for message/data sending during an active remoting | 145 // Error handlers for message/data sending during an active remoting |
| 146 // session. When a failure occurs, these immediately force-stop remoting. | 146 // session. When a failure occurs, these immediately force-stop remoting. |
| 147 void HandleSendMessageResult(bool success); | 147 void HandleSendMessageResult(bool success); |
| 148 void OnDataSendFailed(); | 148 void OnDataSendFailed(); |
| 149 | 149 |
| 150 // MediaRoutesObserver implementation: Scans |routes| to check whether the | 150 // MediaRoutesObserver implementation: Scans |routes| to check whether the |
| 151 // existing remoting route has gone away and/or there is a new remoting route | 151 // existing remoting route has gone away and/or there is a new remoting route |
| 152 // established, and take the necessary actions to notify sources and/or | 152 // established, and take the necessary actions to notify sources and/or |
| 153 // shutdown an active remoting session. | 153 // shutdown an active remoting session. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 base::WeakPtrFactory<CastRemotingConnector> weak_factory_; | 198 base::WeakPtrFactory<CastRemotingConnector> weak_factory_; |
| 199 | 199 |
| 200 // Key used with the base::SupportsUserData interface to search for an | 200 // Key used with the base::SupportsUserData interface to search for an |
| 201 // instance of CastRemotingConnector owned by a WebContents. | 201 // instance of CastRemotingConnector owned by a WebContents. |
| 202 static const void* const kUserDataKey; | 202 static const void* const kUserDataKey; |
| 203 | 203 |
| 204 DISALLOW_COPY_AND_ASSIGN(CastRemotingConnector); | 204 DISALLOW_COPY_AND_ASSIGN(CastRemotingConnector); |
| 205 }; | 205 }; |
| 206 | 206 |
| 207 #endif // CHROME_BROWSER_MEDIA_CAST_REMOTING_CONNECTOR_H_ | 207 #endif // CHROME_BROWSER_MEDIA_CAST_REMOTING_CONNECTOR_H_ |
| OLD | NEW |