Commit cd508f21 authored by Florent Castelli's avatar Florent Castelli Committed by Commit Bot

Move ConvertToWebKitRTCError to a separate file

This function is shared with the upcoming RTCRtpSender.setParameters().

Bug: 803494
Change-Id: I4ec8412c63ee4abd98ffc458df73bc9b45e72e87
Reviewed-on: https://chromium-review.googlesource.com/962604
Commit-Queue: Florent Castelli <orphis@chromium.org>
Reviewed-by: default avatarHarald Alvestrand <hta@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543119}
parent f6b06f4d
...@@ -757,6 +757,8 @@ target(link_target_type, "renderer") { ...@@ -757,6 +757,8 @@ target(link_target_type, "renderer") {
"media/webrtc/rtc_data_channel_handler.h", "media/webrtc/rtc_data_channel_handler.h",
"media/webrtc/rtc_dtmf_sender_handler.cc", "media/webrtc/rtc_dtmf_sender_handler.cc",
"media/webrtc/rtc_dtmf_sender_handler.h", "media/webrtc/rtc_dtmf_sender_handler.h",
"media/webrtc/rtc_error.cc",
"media/webrtc/rtc_error.h",
"media/webrtc/rtc_event_log_output_sink.h", "media/webrtc/rtc_event_log_output_sink.h",
"media/webrtc/rtc_event_log_output_sink_proxy.cc", "media/webrtc/rtc_event_log_output_sink_proxy.cc",
"media/webrtc/rtc_event_log_output_sink_proxy.h", "media/webrtc/rtc_event_log_output_sink_proxy.h",
......
// Copyright (c) 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/renderer/media/webrtc/rtc_error.h"
#include "third_party/webrtc/api/rtcerror.h"
namespace content {
blink::WebRTCError ConvertToWebKitRTCError(
const webrtc::RTCError& webrtc_error) {
blink::WebString message = blink::WebString::FromUTF8(
webrtc_error.message(), strlen(webrtc_error.message()));
switch (webrtc_error.type()) {
case webrtc::RTCErrorType::NONE:
return blink::WebRTCError(blink::WebRTCErrorType::kNone, message);
break;
case webrtc::RTCErrorType::UNSUPPORTED_PARAMETER:
return blink::WebRTCError(blink::WebRTCErrorType::kUnsupportedParameter,
message);
break;
case webrtc::RTCErrorType::INVALID_PARAMETER:
return blink::WebRTCError(blink::WebRTCErrorType::kInvalidParameter,
message);
break;
case webrtc::RTCErrorType::INVALID_RANGE:
return blink::WebRTCError(blink::WebRTCErrorType::kInvalidRange, message);
break;
case webrtc::RTCErrorType::SYNTAX_ERROR:
return blink::WebRTCError(blink::WebRTCErrorType::kSyntaxError, message);
break;
case webrtc::RTCErrorType::INVALID_STATE:
return blink::WebRTCError(blink::WebRTCErrorType::kInvalidState, message);
break;
case webrtc::RTCErrorType::INVALID_MODIFICATION:
return blink::WebRTCError(blink::WebRTCErrorType::kInvalidModification,
message);
break;
case webrtc::RTCErrorType::NETWORK_ERROR:
return blink::WebRTCError(blink::WebRTCErrorType::kNetworkError, message);
break;
case webrtc::RTCErrorType::INTERNAL_ERROR:
return blink::WebRTCError(blink::WebRTCErrorType::kInternalError,
message);
break;
default:
// If adding a new error type, need 3 CLs: One to add the enum to webrtc,
// one to update this mapping code, and one to start using the enum in
// webrtc.
NOTREACHED() << "webrtc::RTCErrorType " << webrtc_error.type()
<< " not covered by switch statement.";
break;
}
NOTREACHED();
return blink::WebRTCError(blink::WebRTCErrorType::kInternalError,
"Impossible code path executed");
}
} // namespace content
\ No newline at end of file
// Copyright (c) 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_RENDERER_MEDIA_WEBRTC_RTC_ERROR_H_
#define CONTENT_RENDERER_MEDIA_WEBRTC_RTC_ERROR_H_
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "third_party/WebKit/public/platform/WebRTCError.h"
namespace webrtc {
class RTCError;
}
namespace content {
blink::WebRTCError ConvertToWebKitRTCError(
const webrtc::RTCError& webrtc_error);
}
#endif // CONTENT_RENDERER_MEDIA_WEBRTC_RTC_ERROR_H_
\ No newline at end of file
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "content/renderer/media/webrtc/rtc_certificate.h" #include "content/renderer/media/webrtc/rtc_certificate.h"
#include "content/renderer/media/webrtc/rtc_data_channel_handler.h" #include "content/renderer/media/webrtc/rtc_data_channel_handler.h"
#include "content/renderer/media/webrtc/rtc_dtmf_sender_handler.h" #include "content/renderer/media/webrtc/rtc_dtmf_sender_handler.h"
#include "content/renderer/media/webrtc/rtc_error.h"
#include "content/renderer/media/webrtc/rtc_event_log_output_sink.h" #include "content/renderer/media/webrtc/rtc_event_log_output_sink.h"
#include "content/renderer/media/webrtc/rtc_event_log_output_sink_proxy.h" #include "content/renderer/media/webrtc/rtc_event_log_output_sink_proxy.h"
#include "content/renderer/media/webrtc/rtc_stats.h" #include "content/renderer/media/webrtc/rtc_stats.h"
...@@ -169,55 +170,6 @@ CreateWebKitSessionDescription( ...@@ -169,55 +170,6 @@ CreateWebKitSessionDescription(
return CreateWebKitSessionDescription(sdp, native_desc->type()); return CreateWebKitSessionDescription(sdp, native_desc->type());
} }
blink::WebRTCError ConvertToWebKitRTCError(
const webrtc::RTCError& webrtc_error) {
blink::WebString message = blink::WebString::FromUTF8(
webrtc_error.message(), strlen(webrtc_error.message()));
switch (webrtc_error.type()) {
case webrtc::RTCErrorType::NONE:
return blink::WebRTCError(blink::WebRTCErrorType::kNone, message);
break;
case webrtc::RTCErrorType::UNSUPPORTED_PARAMETER:
return blink::WebRTCError(blink::WebRTCErrorType::kUnsupportedParameter,
message);
break;
case webrtc::RTCErrorType::INVALID_PARAMETER:
return blink::WebRTCError(blink::WebRTCErrorType::kInvalidParameter,
message);
break;
case webrtc::RTCErrorType::INVALID_RANGE:
return blink::WebRTCError(blink::WebRTCErrorType::kInvalidRange, message);
break;
case webrtc::RTCErrorType::SYNTAX_ERROR:
return blink::WebRTCError(blink::WebRTCErrorType::kSyntaxError, message);
break;
case webrtc::RTCErrorType::INVALID_STATE:
return blink::WebRTCError(blink::WebRTCErrorType::kInvalidState, message);
break;
case webrtc::RTCErrorType::INVALID_MODIFICATION:
return blink::WebRTCError(blink::WebRTCErrorType::kInvalidModification,
message);
break;
case webrtc::RTCErrorType::NETWORK_ERROR:
return blink::WebRTCError(blink::WebRTCErrorType::kNetworkError, message);
break;
case webrtc::RTCErrorType::INTERNAL_ERROR:
return blink::WebRTCError(blink::WebRTCErrorType::kInternalError,
message);
break;
default:
// If adding a new error type, need 3 CLs: One to add the enum to webrtc,
// one to update this mapping code, and one to start using the enum in
// webrtc.
NOTREACHED() << "webrtc::RTCErrorType " << webrtc_error.type()
<< " not covered by switch statement.";
break;
}
NOTREACHED();
return blink::WebRTCError(blink::WebRTCErrorType::kInternalError,
"Impossible code path executed");
}
void RunClosureWithTrace(const base::Closure& closure, void RunClosureWithTrace(const base::Closure& closure,
const char* trace_event_name) { const char* trace_event_name) {
TRACE_EVENT0("webrtc", trace_event_name); TRACE_EVENT0("webrtc", trace_event_name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment