diff --git a/api/jsep.cc b/api/jsep.cc index 5fdc8905c7..ddb39b6181 100644 --- a/api/jsep.cc +++ b/api/jsep.cc @@ -21,6 +21,23 @@ size_t SessionDescriptionInterface::RemoveCandidates( return 0; } +void CreateSessionDescriptionObserver::OnFailure(RTCError error) { + OnFailure(error.message()); +} + +void CreateSessionDescriptionObserver::OnFailure(const std::string& error) { + OnFailure(RTCError(RTCErrorType::INTERNAL_ERROR, std::string(error))); +} + +void SetSessionDescriptionObserver::OnFailure(RTCError error) { + std::string message(error.message()); + OnFailure(message); +} + +void SetSessionDescriptionObserver::OnFailure(const std::string& error) { + OnFailure(RTCError(RTCErrorType::INTERNAL_ERROR, std::string(error))); +} + const char SessionDescriptionInterface::kOffer[] = "offer"; const char SessionDescriptionInterface::kPrAnswer[] = "pranswer"; const char SessionDescriptionInterface::kAnswer[] = "answer"; diff --git a/api/jsep.h b/api/jsep.h index cf8aeb0cb4..86f4162f84 100644 --- a/api/jsep.h +++ b/api/jsep.h @@ -28,7 +28,6 @@ #include "absl/types/optional.h" #include "api/rtc_error.h" -#include "rtc_base/deprecation.h" #include "rtc_base/ref_count.h" #include "rtc_base/system/rtc_export.h" @@ -223,9 +222,11 @@ class RTC_EXPORT CreateSessionDescriptionObserver // error code and a string. // RTCError is non-copyable, so it must be passed using std::move. // Earlier versions of the API used a string argument. This version - // is removed; its functionality was the same as passing - // error.message. - virtual void OnFailure(RTCError error) = 0; + // is deprecated; in order to let clients remove the old version, it has a + // default implementation. If both versions are unimplemented, the + // result will be a runtime error (stack overflow). This is intentional. + virtual void OnFailure(RTCError error); + virtual void OnFailure(const std::string& error); protected: ~CreateSessionDescriptionObserver() override = default; @@ -236,7 +237,9 @@ class RTC_EXPORT SetSessionDescriptionObserver : public rtc::RefCountInterface { public: virtual void OnSuccess() = 0; // See description in CreateSessionDescriptionObserver for OnFailure. - virtual void OnFailure(RTCError error) = 0; + virtual void OnFailure(RTCError error); + + virtual void OnFailure(const std::string& error); protected: ~SetSessionDescriptionObserver() override = default;