Commit 92f3e151 authored by Philippe Gorley's avatar Philippe Gorley Committed by Sébastien Blin

recorder: change title and description

Recorder replaces "%TIMESTAMP" with the start time of the recording.

SIP calls now have the title: "Conversation at %TIMESTAMP
between USER1 and USER2", where the registered username is used if
possible, else falls back on the ring id.

Change-Id: Idd65917173861b395a4bb1476274727679b087b3
Reviewed-by: Sébastien Blin's avatarSebastien Blin <sebastien.blin@savoirfairelinux.com>
parent c17099ae
......@@ -39,6 +39,20 @@ namespace ring {
static constexpr auto FRAME_DEQUEUE_INTERVAL = std::chrono::milliseconds(200);
static std::string
replaceAll(const std::string& str, const std::string& from, const std::string& to)
{
if (from.empty())
return str;
std::string copy(str);
size_t startPos = 0;
while ((startPos = str.find(from, startPos)) != std::string::npos) {
copy.replace(startPos, from.length(), to);
startPos += to.length();
}
return copy;
}
MediaRecorder::MediaRecorder()
: loop_([]{ return true;},
[this]{ process(); },
......@@ -224,19 +238,21 @@ MediaRecorder::initRecord()
std::map<std::string, std::string> encoderOptions;
std::stringstream timestampString;
timestampString << std::put_time(&startTime_, "%Y-%m-%d %H:%M:%S");
if (title_.empty()) {
std::stringstream ss;
ss << "Ring recording at " << std::put_time(&startTime_, "%Y-%m-%d %H:%M:%S");
ss << "Conversation at %TIMESTAMP";
title_ = ss.str();
}
title_ = replaceAll(title_, "%TIMESTAMP", timestampString.str());
encoderOptions["title"] = title_;
if (description_.empty()) {
std::stringstream ss;
ss << "Recorded at " << std::put_time(&startTime_, "%Y-%m-%d %H:%M:%S")
<< " with Ring https://ring.cx";
description_ = ss.str();
description_ = "Recorded with Ring https://ring.cx";
}
description_ = replaceAll(description_, "%TIMESTAMP", timestampString.str());
encoderOptions["description"] = description_;
videoFilter_.reset();
......
......@@ -50,8 +50,9 @@ class MediaRecorder {
void audioOnly(bool audioOnly);
// default title is: "Ring recording at %Y-%m-%d %H:%M:%S"
// default description is: "Recorded at %Y-%m-%d %H:%M:%S with Ring https://ring.cx"
// replaces %TIMESTAMP with time at start of recording
// default title: "Conversation at %Y-%m-%d %H:%M:%S"
// default description: "Recorded with Ring https://ring.cx"
void setMetadata(const std::string& title, const std::string& desc);
[[deprecated("use setPath to set full recording path")]]
......
......@@ -1155,7 +1155,8 @@ SIPCall::toggleRecording()
const bool startRecording = Call::toggleRecording();
if (startRecording) {
std::stringstream ss;
ss << "Ring call between " << getSIPAccount().getUserUri() << " and " << peerUri_;
ss << "Conversation at %TIMESTAMP between "
<< getSIPAccount().getUserUri() << " and " << peerUri_;
recorder_->setMetadata(ss.str(), ""); // use default description
if (avformatrtp_)
avformatrtp_->startRecorder(recorder_);
......
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