Skip to content
Snippets Groups Projects
Commit 92f3e151 authored by Philippe Gorley's avatar Philippe Gorley Committed by Sébastien Blin
Browse files

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: default avatarSebastien Blin <sebastien.blin@savoirfairelinux.com>
parent c17099ae
No related branches found
No related tags found
No related merge requests found
...@@ -39,6 +39,20 @@ namespace ring { ...@@ -39,6 +39,20 @@ namespace ring {
static constexpr auto FRAME_DEQUEUE_INTERVAL = std::chrono::milliseconds(200); 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() MediaRecorder::MediaRecorder()
: loop_([]{ return true;}, : loop_([]{ return true;},
[this]{ process(); }, [this]{ process(); },
...@@ -224,19 +238,21 @@ MediaRecorder::initRecord() ...@@ -224,19 +238,21 @@ MediaRecorder::initRecord()
std::map<std::string, std::string> encoderOptions; std::map<std::string, std::string> encoderOptions;
std::stringstream timestampString;
timestampString << std::put_time(&startTime_, "%Y-%m-%d %H:%M:%S");
if (title_.empty()) { if (title_.empty()) {
std::stringstream ss; 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_ = ss.str();
} }
title_ = replaceAll(title_, "%TIMESTAMP", timestampString.str());
encoderOptions["title"] = title_; encoderOptions["title"] = title_;
if (description_.empty()) { if (description_.empty()) {
std::stringstream ss; description_ = "Recorded with Ring https://ring.cx";
ss << "Recorded at " << std::put_time(&startTime_, "%Y-%m-%d %H:%M:%S")
<< " with Ring https://ring.cx";
description_ = ss.str();
} }
description_ = replaceAll(description_, "%TIMESTAMP", timestampString.str());
encoderOptions["description"] = description_; encoderOptions["description"] = description_;
videoFilter_.reset(); videoFilter_.reset();
......
...@@ -50,8 +50,9 @@ class MediaRecorder { ...@@ -50,8 +50,9 @@ class MediaRecorder {
void audioOnly(bool audioOnly); void audioOnly(bool audioOnly);
// default title is: "Ring recording at %Y-%m-%d %H:%M:%S" // replaces %TIMESTAMP with time at start of recording
// default description is: "Recorded at %Y-%m-%d %H:%M:%S with Ring https://ring.cx" // 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); void setMetadata(const std::string& title, const std::string& desc);
[[deprecated("use setPath to set full recording path")]] [[deprecated("use setPath to set full recording path")]]
......
...@@ -1155,7 +1155,8 @@ SIPCall::toggleRecording() ...@@ -1155,7 +1155,8 @@ SIPCall::toggleRecording()
const bool startRecording = Call::toggleRecording(); const bool startRecording = Call::toggleRecording();
if (startRecording) { if (startRecording) {
std::stringstream ss; 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 recorder_->setMetadata(ss.str(), ""); // use default description
if (avformatrtp_) if (avformatrtp_)
avformatrtp_->startRecorder(recorder_); avformatrtp_->startRecorder(recorder_);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment