fake_webrtc_connection.cc 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2019 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. #include "remoting/test/fake_webrtc_connection.h"
  5. #include "components/webrtc/thread_wrapper.h"
  6. #include "remoting/base/logging.h"
  7. #include "remoting/protocol/transport_context.h"
  8. namespace remoting {
  9. namespace test {
  10. FakeWebrtcConnection::FakeWebrtcConnection(
  11. scoped_refptr<protocol::TransportContext> transport_context,
  12. base::OnceClosure on_closed) {
  13. // TODO(lambroslambrou): Passing nullptr for the VideoEncoderFactory may
  14. // break the ftl_signaling_playground executable. If needed, this should be
  15. // replaced with a factory that supports at least one video codec.
  16. transport_ = std::make_unique<protocol::WebrtcTransport>(
  17. webrtc::ThreadWrapper::current(), transport_context, nullptr, this);
  18. on_closed_ = std::move(on_closed);
  19. }
  20. FakeWebrtcConnection::~FakeWebrtcConnection() = default;
  21. void FakeWebrtcConnection::OnWebrtcTransportConnecting() {
  22. HOST_LOG << "Webrtc transport is connecting...";
  23. }
  24. void FakeWebrtcConnection::OnWebrtcTransportConnected() {
  25. HOST_LOG << "Webrtc transport is connected!!!";
  26. std::move(on_closed_).Run();
  27. }
  28. void FakeWebrtcConnection::OnWebrtcTransportError(protocol::ErrorCode error) {
  29. LOG(ERROR) << "Webrtc transport error: " << error;
  30. std::move(on_closed_).Run();
  31. }
  32. void FakeWebrtcConnection::OnWebrtcTransportProtocolChanged() {}
  33. void FakeWebrtcConnection::OnWebrtcTransportIncomingDataChannel(
  34. const std::string& name,
  35. std::unique_ptr<protocol::MessagePipe> pipe) {}
  36. void FakeWebrtcConnection::OnWebrtcTransportMediaStreamAdded(
  37. rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) {}
  38. void FakeWebrtcConnection::OnWebrtcTransportMediaStreamRemoved(
  39. rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) {}
  40. void FakeWebrtcConnection::OnWebrtcTransportRouteChanged(
  41. const protocol::TransportRoute& route) {}
  42. } // namespace test
  43. } // namespace remoting