CreateSessionDescriptionObserver.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #include "pch.h"
  2. #include "PeerConnectionObject.h"
  3. #include "CreateSessionDescriptionObserver.h"
  4. namespace unity
  5. {
  6. namespace webrtc
  7. {
  8. DelegateCreateSessionDesc CreateSessionDescriptionObserver::s_createSessionDescCallback = nullptr;
  9. rtc::scoped_refptr<CreateSessionDescriptionObserver>
  10. CreateSessionDescriptionObserver::Create(PeerConnectionObject* connection)
  11. {
  12. return new rtc::RefCountedObject<CreateSessionDescriptionObserver>(connection);
  13. }
  14. CreateSessionDescriptionObserver::CreateSessionDescriptionObserver(PeerConnectionObject* connection)
  15. {
  16. m_connection = connection;
  17. }
  18. void CreateSessionDescriptionObserver::OnSuccess(SessionDescriptionInterface* desc)
  19. {
  20. std::string out;
  21. desc->ToString(&out);
  22. const auto sdpType = ConvertSdpType(desc->GetType());
  23. s_createSessionDescCallback(m_connection, this, sdpType, out.c_str(), RTCErrorType::NONE, nullptr);
  24. }
  25. void CreateSessionDescriptionObserver::OnFailure(webrtc::RTCError error)
  26. {
  27. s_createSessionDescCallback(m_connection, this, RTCSdpType(), nullptr, error.type(), error.message());
  28. }
  29. } // end namespace webrtc
  30. } // end namespace unity