Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1820)

Unified Diff: webrtc/call/rtc_event_log.cc

Issue 1374253002: Added functions on libjingle API to start and stop the recording of an RtcEventLog. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added functions to start and stop logging. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« webrtc/call/rtc_event_log.h ('K') | « webrtc/call/rtc_event_log.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/call/rtc_event_log.cc
diff --git a/webrtc/call/rtc_event_log.cc b/webrtc/call/rtc_event_log.cc
index 23b120cb8ed1fa4348b092561bb2d54cea6562f1..1fb6f97fe451f186438a1260b4769d8221223795 100644
--- a/webrtc/call/rtc_event_log.cc
+++ b/webrtc/call/rtc_event_log.cc
@@ -11,6 +11,7 @@
#include "webrtc/call/rtc_event_log.h"
#include <deque>
+#include <limits>
#include "webrtc/base/checks.h"
#include "webrtc/base/criticalsection.h"
@@ -37,6 +38,7 @@ namespace webrtc {
class RtcEventLogImpl final : public RtcEventLog {
public:
void StartLogging(const std::string& file_name, int duration_ms) override {}
+ int StartLogging(FILE* log_file) override { return -1; }
void StopLogging(void) override {}
void LogVideoReceiveStreamConfig(
const VideoReceiveStream::Config& config) override {}
@@ -60,6 +62,7 @@ class RtcEventLogImpl final : public RtcEventLog {
RtcEventLogImpl();
void StartLogging(const std::string& file_name, int duration_ms) override;
+ int StartLogging(FILE* log_file) override;
void StopLogging() override;
void LogVideoReceiveStreamConfig(
const VideoReceiveStream::Config& config) override;
@@ -75,6 +78,9 @@ class RtcEventLogImpl final : public RtcEventLog {
void LogAudioPlayout(uint32_t ssrc) override;
private:
+ // Starts logging. This function assumes the file_ has been opened succesfully
+ // and that the start_time_us_ and _duration_us_ have been set.
+ void StartLoggingLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_);
// Stops logging and clears the stored data and buffers.
void StopLoggingLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_);
// Adds a new event to the logfile if logging is active, or adds it to the
@@ -159,9 +165,29 @@ void RtcEventLogImpl::StartLogging(const std::string& file_name,
if (file_->OpenFile(file_name.c_str(), false) != 0) {
return;
}
- currently_logging_ = true;
start_time_us_ = clock_->TimeInMicroseconds();
duration_us_ = static_cast<int64_t>(duration_ms) * 1000;
+ StartLoggingLocked();
+}
+
+int RtcEventLogImpl::StartLogging(FILE* log_file) {
+ rtc::CritScope lock(&crit_);
+
+ if (currently_logging_)
+ StopLoggingLocked();
+ RTC_DCHECK(log_file);
+ if (file_->OpenFromFileHandle(log_file, true, false) != 0) {
+ return -1;
+ }
+ // Set the start time and duration to keep logging for 10 minutes.
+ start_time_us_ = clock_->TimeInMicroseconds();
+ duration_us_ = 10 * 60 * 1000000;
+ StartLoggingLocked();
+ return 0;
+}
+
+void RtcEventLogImpl::StartLoggingLocked() {
+ currently_logging_ = true;
// Write all the recent events to the log file, ignoring any old events.
for (auto& event : recent_log_events_) {
if (event.timestamp_us() >= start_time_us_ - recent_log_duration_us) {
« webrtc/call/rtc_event_log.h ('K') | « webrtc/call/rtc_event_log.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698