Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Side by Side Diff: extensions/renderer/api/display_source/wifi_display/wifi_display_session.h

Issue 1698473004: [chrome.displaySource] Use WDS for Wi-Fi Display implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from Antony + rebase + GN build fix Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_SESSION _H_ 5 #ifndef EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_SESSION _H_
6 #define EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_SESSION _H_ 6 #define EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_SESSION _H_
7 7
8 #include <map>
8 #include <string> 9 #include <string>
9 10
10 #include "extensions/common/mojo/wifi_display_session_service.mojom.h" 11 #include "extensions/common/mojo/wifi_display_session_service.mojom.h"
11 #include "extensions/renderer/api/display_source/display_source_session.h" 12 #include "extensions/renderer/api/display_source/display_source_session.h"
12 #include "mojo/public/cpp/bindings/binding.h" 13 #include "mojo/public/cpp/bindings/binding.h"
14 #include "third_party/wds/src/libwds/public/source.h"
15
16 namespace base {
17 class Timer;
18 } // namespace base
13 19
14 namespace extensions { 20 namespace extensions {
15 21
22 class WiFiDisplayMediaManager;
23
24 // This class represents a single Wi-Fi Display session.
25 // It manages life-cycle of the session and it is also responsible for
26 // exchange of session controlling (RTSP) messages with the sink.
16 class WiFiDisplaySession: public DisplaySourceSession, 27 class WiFiDisplaySession: public DisplaySourceSession,
17 public WiFiDisplaySessionServiceClient { 28 public WiFiDisplaySessionServiceClient,
29 public wds::Peer::Delegate,
30 public wds::Peer::Observer {
18 public: 31 public:
19 explicit WiFiDisplaySession( 32 explicit WiFiDisplaySession(
20 const DisplaySourceSessionParams& params); 33 const DisplaySourceSessionParams& params);
21 ~WiFiDisplaySession() override; 34 ~WiFiDisplaySession() override;
22 35
23 private: 36 private:
24 using DisplaySourceSession::CompletionCallback; 37 using DisplaySourceSession::CompletionCallback;
25 // DisplaySourceSession overrides. 38 // DisplaySourceSession overrides.
26 void Start(const CompletionCallback& callback) override; 39 void Start(const CompletionCallback& callback) override;
27 void Terminate(const CompletionCallback& callback) override; 40 void Terminate(const CompletionCallback& callback) override;
28 41
29 // WiFiDisplaySessionServiceClient overrides. 42 // WiFiDisplaySessionServiceClient overrides.
30 void OnConnected(const mojo::String& ip_address) override; 43 void OnConnected(const mojo::String& ip_address) override;
31 void OnConnectRequestHandled(bool success, 44 void OnConnectRequestHandled(bool success,
32 const mojo::String& error) override; 45 const mojo::String& error) override;
33 void OnTerminated() override; 46 void OnTerminated() override;
34 void OnDisconnectRequestHandled(bool success, 47 void OnDisconnectRequestHandled(bool success,
35 const mojo::String& error) override; 48 const mojo::String& error) override;
36 void OnError(int32_t type, const mojo::String& description) override; 49 void OnError(int32_t type, const mojo::String& description) override;
37 void OnMessage(const mojo::String& data) override; 50 void OnMessage(const mojo::String& data) override;
38 51
52 // wds::Peer::Delegate overrides.
53 unsigned CreateTimer(int seconds) override;
54 void ReleaseTimer(unsigned timer_id) override;
55 void SendRTSPData(const std::string& message) override;
56 std::string GetLocalIPAddress() const override;
57 int GetNextCSeq(int* initial_peer_cseq = nullptr) const override;
58
59 // wds::Peer::Observer overrides.
60 void ErrorOccurred(wds::ErrorType error) override;
61 void SessionCompleted() override;
62
39 // A connection error handler for the mojo objects used in this class. 63 // A connection error handler for the mojo objects used in this class.
40 void OnConnectionError(); 64 void OnIPCConnectionError();
41 65
42 void RunStartCallback(bool success, const std::string& error = ""); 66 void RunStartCallback(bool success, const std::string& error = "");
43 void RunTerminateCallback(bool success, const std::string& error = ""); 67 void RunTerminateCallback(bool success, const std::string& error = "");
44 68
45 private: 69 private:
70 scoped_ptr<wds::Source> wfd_source_;
71 scoped_ptr<WiFiDisplayMediaManager> media_manager_;
46 WiFiDisplaySessionServicePtr service_; 72 WiFiDisplaySessionServicePtr service_;
47 mojo::Binding<WiFiDisplaySessionServiceClient> binding_; 73 mojo::Binding<WiFiDisplaySessionServiceClient> binding_;
48 std::string ip_address_; 74 std::string ip_address_;
75 std::map<int, scoped_ptr<base::Timer>> timers_;
76
49 DisplaySourceSessionParams params_; 77 DisplaySourceSessionParams params_;
50 CompletionCallback start_completion_callback_; 78 CompletionCallback start_completion_callback_;
51 CompletionCallback teminate_completion_callback_; 79 CompletionCallback teminate_completion_callback_;
80 // Holds sequence number for the following RTSP request-response pair.
81 mutable int cseq_;
82 int timer_id_;
52 base::WeakPtrFactory<WiFiDisplaySession> weak_factory_; 83 base::WeakPtrFactory<WiFiDisplaySession> weak_factory_;
53 84
54 DISALLOW_COPY_AND_ASSIGN(WiFiDisplaySession); 85 DISALLOW_COPY_AND_ASSIGN(WiFiDisplaySession);
55 }; 86 };
56 87
57 } // namespace extensions 88 } // namespace extensions
58 89
59 #endif // EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_SESS ION_H_ 90 #endif // EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_SESS ION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698