Delete obsolete RtcEventLogOutputFile constructor
Followup to https://webrtc-review.googlesource.com/c/src/+/134460.
Bug: webrtc:6463
Change-Id: Ib6574b02b21fddc598c1f67c7e2b515f01d33204
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/139887
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28206}
diff --git a/api/rtc_event_log_output_file.cc b/api/rtc_event_log_output_file.cc
index c300a54..404eb31 100644
--- a/api/rtc_event_log_output_file.cc
+++ b/api/rtc_event_log_output_file.cc
@@ -18,17 +18,6 @@
namespace webrtc {
-namespace {
-
-FileWrapper FileWrapperFromPlatformFile(rtc::PlatformFile platform_file) {
- if (platform_file == rtc::kInvalidPlatformFileValue)
- return FileWrapper();
-
- return FileWrapper(rtc::FdopenPlatformFileForWriting(platform_file));
-}
-
-} // namespace
-
// Together with the assumption of no single Write() would ever be called on
// an input with length greater-than-or-equal-to (max(size_t) / 2), this
// guarantees no overflow of the check for remaining file capacity in Write().
@@ -60,11 +49,6 @@
}
}
-RtcEventLogOutputFile::RtcEventLogOutputFile(rtc::PlatformFile platform_file,
- size_t max_size_bytes)
- : RtcEventLogOutputFile(FileWrapperFromPlatformFile(platform_file),
- max_size_bytes) {}
-
bool RtcEventLogOutputFile::IsActive() const {
return IsActiveInternal();
}
diff --git a/api/rtc_event_log_output_file.h b/api/rtc_event_log_output_file.h
index e536dfc..e1d18e0 100644
--- a/api/rtc_event_log_output_file.h
+++ b/api/rtc_event_log_output_file.h
@@ -16,7 +16,6 @@
#include <string>
#include "api/rtc_event_log_output.h"
-#include "rtc_base/platform_file.h" // Can't neatly forward PlatformFile.
#include "rtc_base/system/file_wrapper.h"
namespace webrtc {
@@ -33,10 +32,6 @@
// of the FILE*, and closes it on destruction.
RtcEventLogOutputFile(FILE* file, size_t max_size_bytes);
- // TODO(bugs.webrtc.org/6463): Deprecated, delete together with the
- // corresponding PeerConnection::StartRtcEventLog override.
- RtcEventLogOutputFile(rtc::PlatformFile file, size_t max_size_bytes);
-
~RtcEventLogOutputFile() override = default;
bool IsActive() const override;
diff --git a/pc/peer_connection_interface_unittest.cc b/pc/peer_connection_interface_unittest.cc
index 4549912..2ea3e86 100644
--- a/pc/peer_connection_interface_unittest.cc
+++ b/pc/peer_connection_interface_unittest.cc
@@ -451,6 +451,12 @@
"inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj|2^20|1:32 "
"dummy_session_params\r\n";
+class RtcEventLogOutputNull final : public RtcEventLogOutput {
+ public:
+ bool IsActive() const override { return true; }
+ bool Write(const std::string& output) override { return true; }
+};
+
using ::cricket::StreamParams;
using ::testing::Exactly;
using ::testing::Values;
@@ -3453,11 +3459,9 @@
// The RtcEventLog will be reset when the PeerConnection is closed.
pc_->Close();
- rtc::PlatformFile file = 0;
- int64_t max_size_bytes = 1024;
- EXPECT_FALSE(pc_->StartRtcEventLog(
- absl::make_unique<webrtc::RtcEventLogOutputFile>(file, max_size_bytes),
- webrtc::RtcEventLog::kImmediateOutput));
+ EXPECT_FALSE(
+ pc_->StartRtcEventLog(absl::make_unique<webrtc::RtcEventLogOutputNull>(),
+ webrtc::RtcEventLog::kImmediateOutput));
pc_->StopRtcEventLog();
}
diff --git a/sdk/android/src/jni/pc/peer_connection.cc b/sdk/android/src/jni/pc/peer_connection.cc
index 1e3a73d..311ceaf 100644
--- a/sdk/android/src/jni/pc/peer_connection.cc
+++ b/sdk/android/src/jni/pc/peer_connection.cc
@@ -750,8 +750,13 @@
const size_t max_size = (max_size_bytes < 0)
? RtcEventLog::kUnlimitedOutput
: rtc::saturated_cast<size_t>(max_size_bytes);
+ FILE* f = fdopen(file_descriptor, "wb");
+ if (!f) {
+ close(file_descriptor);
+ return false;
+ }
return ExtractNativePC(jni, j_pc)->StartRtcEventLog(
- absl::make_unique<RtcEventLogOutputFile>(file_descriptor, max_size));
+ absl::make_unique<RtcEventLogOutputFile>(f, max_size));
}
static void JNI_PeerConnection_StopRtcEventLog(
diff --git a/sdk/objc/api/peerconnection/RTCPeerConnection.mm b/sdk/objc/api/peerconnection/RTCPeerConnection.mm
index bed85f9..04b07f7 100644
--- a/sdk/objc/api/peerconnection/RTCPeerConnection.mm
+++ b/sdk/objc/api/peerconnection/RTCPeerConnection.mm
@@ -536,9 +536,8 @@
RTCLogError(@"Event logging already started.");
return NO;
}
- int fd = open(filePath.UTF8String, O_WRONLY | O_CREAT | O_TRUNC,
- S_IRUSR | S_IWUSR);
- if (fd < 0) {
+ FILE *f = fopen(filePath.UTF8String, "wb");
+ if (!f) {
RTCLogError(@"Error opening file: %@. Error: %d", filePath, errno);
return NO;
}
@@ -547,7 +546,7 @@
rtc::saturated_cast<size_t>(maxSizeInBytes);
_hasStartedRtcEventLog = _peerConnection->StartRtcEventLog(
- absl::make_unique<webrtc::RtcEventLogOutputFile>(fd, max_size));
+ absl::make_unique<webrtc::RtcEventLogOutputFile>(f, max_size));
return _hasStartedRtcEventLog;
}