| 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 #include "extensions/renderer/api/display_source/wifi_display/wifi_display_sessi
on.h" | 5 #include "extensions/renderer/api/display_source/wifi_display/wifi_display_sessi
on.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 state_ = DisplaySourceSession::Establishing; | 67 state_ = DisplaySourceSession::Establishing; |
| 68 start_completion_callback_ = callback; | 68 start_completion_callback_ = callback; |
| 69 } | 69 } |
| 70 | 70 |
| 71 void WiFiDisplaySession::Terminate(const CompletionCallback& callback) { | 71 void WiFiDisplaySession::Terminate(const CompletionCallback& callback) { |
| 72 DCHECK_EQ(DisplaySourceSession::Established, state_); | 72 DCHECK_EQ(DisplaySourceSession::Established, state_); |
| 73 Terminate(); | 73 Terminate(); |
| 74 teminate_completion_callback_ = callback; | 74 teminate_completion_callback_ = callback; |
| 75 } | 75 } |
| 76 | 76 |
| 77 void WiFiDisplaySession::OnConnected(const mojo::String& local_ip_address, | 77 void WiFiDisplaySession::OnConnected(const std::string& local_ip_address, |
| 78 const mojo::String& sink_ip_address) { | 78 const std::string& sink_ip_address) { |
| 79 DCHECK_EQ(DisplaySourceSession::Established, state_); | 79 DCHECK_EQ(DisplaySourceSession::Established, state_); |
| 80 local_ip_address_ = local_ip_address; | 80 local_ip_address_ = local_ip_address; |
| 81 media_manager_.reset( | 81 media_manager_.reset( |
| 82 new WiFiDisplayMediaManager( | 82 new WiFiDisplayMediaManager( |
| 83 params_.video_track, | 83 params_.video_track, |
| 84 params_.audio_track, | 84 params_.audio_track, |
| 85 sink_ip_address, | 85 sink_ip_address, |
| 86 params_.render_frame->GetRemoteInterfaces(), | 86 params_.render_frame->GetRemoteInterfaces(), |
| 87 base::Bind( | 87 base::Bind( |
| 88 &WiFiDisplaySession::OnMediaError, | 88 &WiFiDisplaySession::OnMediaError, |
| 89 weak_factory_.GetWeakPtr()))); | 89 weak_factory_.GetWeakPtr()))); |
| 90 wfd_source_.reset(wds::Source::Create(this, media_manager_.get(), this)); | 90 wfd_source_.reset(wds::Source::Create(this, media_manager_.get(), this)); |
| 91 wfd_source_->Start(); | 91 wfd_source_->Start(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void WiFiDisplaySession::OnConnectRequestHandled(bool success, | 94 void WiFiDisplaySession::OnConnectRequestHandled(bool success, |
| 95 const mojo::String& error) { | 95 const std::string& error) { |
| 96 DCHECK_EQ(DisplaySourceSession::Establishing, state_); | 96 DCHECK_EQ(DisplaySourceSession::Establishing, state_); |
| 97 state_ = | 97 state_ = |
| 98 success ? DisplaySourceSession::Established : DisplaySourceSession::Idle; | 98 success ? DisplaySourceSession::Established : DisplaySourceSession::Idle; |
| 99 RunStartCallback(success, error); | 99 RunStartCallback(success, error); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void WiFiDisplaySession::OnTerminated() { | 102 void WiFiDisplaySession::OnTerminated() { |
| 103 DCHECK_NE(DisplaySourceSession::Idle, state_); | 103 DCHECK_NE(DisplaySourceSession::Idle, state_); |
| 104 state_ = DisplaySourceSession::Idle; | 104 state_ = DisplaySourceSession::Idle; |
| 105 media_manager_.reset(); | 105 media_manager_.reset(); |
| 106 wfd_source_.reset(); | 106 wfd_source_.reset(); |
| 107 terminated_callback_.Run(); | 107 terminated_callback_.Run(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void WiFiDisplaySession::OnDisconnectRequestHandled(bool success, | 110 void WiFiDisplaySession::OnDisconnectRequestHandled(bool success, |
| 111 const mojo::String& error) { | 111 const std::string& error) { |
| 112 RunTerminateCallback(success, error); | 112 RunTerminateCallback(success, error); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void WiFiDisplaySession::OnError(int32_t type, | 115 void WiFiDisplaySession::OnError(int32_t type, const std::string& description) { |
| 116 const mojo::String& description) { | |
| 117 DCHECK(type > api::display_source::ERROR_TYPE_NONE | 116 DCHECK(type > api::display_source::ERROR_TYPE_NONE |
| 118 && type <= api::display_source::ERROR_TYPE_LAST); | 117 && type <= api::display_source::ERROR_TYPE_LAST); |
| 119 DCHECK_EQ(DisplaySourceSession::Established, state_); | 118 DCHECK_EQ(DisplaySourceSession::Established, state_); |
| 120 error_callback_.Run(static_cast<ErrorType>(type), description); | 119 error_callback_.Run(static_cast<ErrorType>(type), description); |
| 121 } | 120 } |
| 122 | 121 |
| 123 void WiFiDisplaySession::OnMessage(const mojo::String& data) { | 122 void WiFiDisplaySession::OnMessage(const std::string& data) { |
| 124 DCHECK_EQ(DisplaySourceSession::Established, state_); | 123 DCHECK_EQ(DisplaySourceSession::Established, state_); |
| 125 DCHECK(wfd_source_); | 124 DCHECK(wfd_source_); |
| 126 wfd_source_->RTSPDataReceived(data); | 125 wfd_source_->RTSPDataReceived(data); |
| 127 } | 126 } |
| 128 | 127 |
| 129 std::string WiFiDisplaySession::GetLocalIPAddress() const { | 128 std::string WiFiDisplaySession::GetLocalIPAddress() const { |
| 130 return local_ip_address_; | 129 return local_ip_address_; |
| 131 } | 130 } |
| 132 | 131 |
| 133 int WiFiDisplaySession::GetNextCSeq(int* initial_peer_cseq) const { | 132 int WiFiDisplaySession::GetNextCSeq(int* initial_peer_cseq) const { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 } | 216 } |
| 218 | 217 |
| 219 void WiFiDisplaySession::RunTerminateCallback( | 218 void WiFiDisplaySession::RunTerminateCallback( |
| 220 bool success, | 219 bool success, |
| 221 const std::string& error_message) { | 220 const std::string& error_message) { |
| 222 if (!teminate_completion_callback_.is_null()) | 221 if (!teminate_completion_callback_.is_null()) |
| 223 teminate_completion_callback_.Run(success, error_message); | 222 teminate_completion_callback_.Run(success, error_message); |
| 224 } | 223 } |
| 225 | 224 |
| 226 } // namespace extensions | 225 } // namespace extensions |
| OLD | NEW |