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

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: Rebase and added comment on PeerConnectionFactoryInterface Created 5 years, 2 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
« talk/media/webrtc/webrtcvoiceengine.cc ('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 97885cc066a609d79cf13b69beabc4874d838b57..63d48824581ea487a9c6b0ea3dc3d8d311157c0b 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>
the sun 2015/10/13 11:00:40 where do you use something from limits (in the cha
ivoc 2015/10/13 13:50:50 Thanks, this looks like a leftover of some earlier
#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
@@ -161,9 +167,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) {
« talk/media/webrtc/webrtcvoiceengine.cc ('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