mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-02-07 15:08:24 +00:00
feat(Call): add caller/callee on saved capture files
This commit is contained in:
parent
7c5c1255d5
commit
a58e213568
5 changed files with 74 additions and 30 deletions
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include <QDateTime>
|
||||
#include <QQuickWindow>
|
||||
#include <QRegularExpression>
|
||||
#include <QTimer>
|
||||
|
||||
#include "app/App.hpp"
|
||||
|
|
@ -29,6 +30,7 @@
|
|||
#include "components/core/CoreHandlers.hpp"
|
||||
#include "components/core/CoreManager.hpp"
|
||||
#include "components/notifier/Notifier.hpp"
|
||||
#include "components/settings/AccountSettingsModel.hpp"
|
||||
#include "components/settings/SettingsModel.hpp"
|
||||
#include "utils/LinphoneUtils.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
|
|
@ -92,15 +94,29 @@ QString CallModel::getSipAddress () const {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
void CallModel::setRecordFile (const shared_ptr<linphone::CallParams> &callParams) {
|
||||
callParams->setRecordFile(
|
||||
Utils::appStringToCoreString(
|
||||
QStringLiteral("%1%2.mkv")
|
||||
.arg(CoreManager::getInstance()->getSettingsModel()->getSavedCallsFolder())
|
||||
.arg(QDateTime::currentDateTime().toString("yyyy-MM-dd_hh-mm-ss"))
|
||||
callParams->setRecordFile(Utils::appStringToCoreString(
|
||||
CoreManager::getInstance()->getSettingsModel()->getSavedCallsFolder()
|
||||
.append(generateSavedFilename())
|
||||
.append(".mkv")
|
||||
));
|
||||
}
|
||||
|
||||
void CallModel::setRecordFile (const shared_ptr<linphone::CallParams> &callParams, const QString &to) {
|
||||
const QString from(
|
||||
Utils::coreStringToAppString(
|
||||
CoreManager::getInstance()->getAccountSettingsModel()->getUsedSipAddress()->getUsername()
|
||||
)
|
||||
);
|
||||
|
||||
callParams->setRecordFile(Utils::appStringToCoreString(
|
||||
CoreManager::getInstance()->getSettingsModel()->getSavedCallsFolder()
|
||||
.append(generateSavedFilename(from, to))
|
||||
.append(".mkv")
|
||||
));
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void CallModel::updateStats (const shared_ptr<const linphone::CallStats> &callStats) {
|
||||
switch (callStats->getType()) {
|
||||
case linphone::StreamTypeText:
|
||||
|
|
@ -196,18 +212,17 @@ void CallModel::rejectVideoRequest () {
|
|||
|
||||
void CallModel::takeSnapshot () {
|
||||
static QString oldName;
|
||||
QString newName = QDateTime::currentDateTime().toString("yyyy-MM-dd_hh-mm-ss") + ".jpg";
|
||||
QString newName(generateSavedFilename().append(".jpg"));
|
||||
|
||||
if (newName == oldName) {
|
||||
qWarning() << QStringLiteral("Unable to take snapshot. Wait one second.");
|
||||
return;
|
||||
}
|
||||
|
||||
oldName = newName;
|
||||
|
||||
qInfo() << QStringLiteral("Take snapshot of call:") << this;
|
||||
|
||||
const QString filePath = CoreManager::getInstance()->getSettingsModel()->getSavedScreenshotsFolder() + newName;
|
||||
const QString filePath(CoreManager::getInstance()->getSettingsModel()->getSavedScreenshotsFolder().append(newName));
|
||||
mCall->takeVideoSnapshot(Utils::appStringToCoreString(filePath));
|
||||
App::getInstance()->getNotifier()->notifySnapshotWasTaken(filePath);
|
||||
}
|
||||
|
|
@ -731,3 +746,26 @@ QString CallModel::iceStateToString (linphone::IceState state) const {
|
|||
|
||||
return tr("iceStateInvalid");
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString CallModel::generateSavedFilename () const {
|
||||
const shared_ptr<linphone::CallLog> callLog(mCall->getCallLog());
|
||||
return generateSavedFilename(
|
||||
Utils::coreStringToAppString(callLog->getFromAddress()->getUsername()),
|
||||
Utils::coreStringToAppString(callLog->getToAddress()->getUsername())
|
||||
);
|
||||
}
|
||||
|
||||
QString CallModel::generateSavedFilename (const QString &from, const QString &to) {
|
||||
auto escape = [](const QString &str) {
|
||||
constexpr char ReservedCharacters[] = "<>:\"/\\|\\?\\*";
|
||||
static QRegularExpression regexp(ReservedCharacters);
|
||||
return QString(str).replace(regexp, "");
|
||||
};
|
||||
|
||||
return QStringLiteral("%1_%2_%3")
|
||||
.arg(QDateTime::currentDateTime().toString("yyyy-MM-dd_hh-mm-ss"))
|
||||
.arg(escape(from))
|
||||
.arg(escape(to));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,7 +97,9 @@ public:
|
|||
return mIsInConference;
|
||||
}
|
||||
|
||||
static void setRecordFile (const std::shared_ptr<linphone::CallParams> &callParams);
|
||||
void setRecordFile (const std::shared_ptr<linphone::CallParams> &callParams);
|
||||
static void setRecordFile (const std::shared_ptr<linphone::CallParams> &callParams, const QString &to);
|
||||
|
||||
void updateStats (const std::shared_ptr<const linphone::CallStats> &callStats);
|
||||
|
||||
void notifyCameraFirstFrameReceived (unsigned int width, unsigned int height);
|
||||
|
|
@ -198,6 +200,10 @@ private:
|
|||
float getMicroVolumeGain () const;
|
||||
void setMicroVolumeGain (float volume);
|
||||
|
||||
QString generateSavedFilename () const;
|
||||
|
||||
static QString generateSavedFilename (const QString &from, const QString &to);
|
||||
|
||||
bool mIsInConference = false;
|
||||
|
||||
bool mPausedByRemote = false;
|
||||
|
|
|
|||
|
|
@ -107,7 +107,6 @@ void CallsListModel::launchAudioCall (const QString &sipAddress, const QHash<QSt
|
|||
|
||||
shared_ptr<linphone::CallParams> params = core->createCallParams(nullptr);
|
||||
params->enableVideo(false);
|
||||
CallModel::setRecordFile(params);
|
||||
|
||||
QHashIterator<QString, QString> iterator(headers);
|
||||
while (iterator.hasNext()) {
|
||||
|
|
@ -115,6 +114,7 @@ void CallsListModel::launchAudioCall (const QString &sipAddress, const QHash<QSt
|
|||
params->addCustomHeader(Utils::appStringToCoreString(iterator.key()), Utils::appStringToCoreString(iterator.value()));
|
||||
}
|
||||
|
||||
CallModel::setRecordFile(params, Utils::coreStringToAppString(address->getUsername()));
|
||||
core->inviteAddressWithParams(address, params);
|
||||
}
|
||||
|
||||
|
|
@ -133,8 +133,8 @@ void CallsListModel::launchVideoCall (const QString &sipAddress) const {
|
|||
shared_ptr<linphone::CallParams> params = core->createCallParams(nullptr);
|
||||
params->enableEarlyMediaSending(true);
|
||||
params->enableVideo(true);
|
||||
CallModel::setRecordFile(params);
|
||||
|
||||
CallModel::setRecordFile(params, Utils::coreStringToAppString(address->getUsername()));
|
||||
core->inviteAddressWithParams(address, params);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,6 +62,22 @@ AccountSettingsModel::AccountSettingsModel (QObject *parent) : QObject(parent) {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
shared_ptr<const linphone::Address> AccountSettingsModel::getUsedSipAddress () const {
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
shared_ptr<linphone::ProxyConfig> proxyConfig = core->getDefaultProxyConfig();
|
||||
|
||||
return proxyConfig ? proxyConfig->getIdentityAddress() : core->getPrimaryContactParsed();
|
||||
}
|
||||
|
||||
void AccountSettingsModel::setUsedSipAddress (const shared_ptr<const linphone::Address> &address) {
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
shared_ptr<linphone::ProxyConfig> proxyConfig = core->getDefaultProxyConfig();
|
||||
|
||||
proxyConfig ? proxyConfig->setIdentityAddress(address) : core->setPrimaryContact(address->asString());
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
bool AccountSettingsModel::addOrUpdateProxyConfig (const shared_ptr<linphone::ProxyConfig> &proxyConfig) {
|
||||
Q_CHECK_PTR(proxyConfig);
|
||||
|
||||
|
|
@ -342,22 +358,6 @@ QVariantList AccountSettingsModel::getAccounts () const {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void AccountSettingsModel::setUsedSipAddress (const shared_ptr<const linphone::Address> &address) {
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
shared_ptr<linphone::ProxyConfig> proxyConfig = core->getDefaultProxyConfig();
|
||||
|
||||
proxyConfig ? proxyConfig->setIdentityAddress(address) : core->setPrimaryContact(address->asString());
|
||||
}
|
||||
|
||||
shared_ptr<const linphone::Address> AccountSettingsModel::getUsedSipAddress () const {
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
shared_ptr<linphone::ProxyConfig> proxyConfig = core->getDefaultProxyConfig();
|
||||
|
||||
return proxyConfig ? proxyConfig->getIdentityAddress() : core->getPrimaryContactParsed();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void AccountSettingsModel::handleRegistrationStateChanged (
|
||||
const shared_ptr<linphone::ProxyConfig> &,
|
||||
linphone::RegistrationState
|
||||
|
|
|
|||
|
|
@ -53,6 +53,9 @@ public:
|
|||
|
||||
AccountSettingsModel (QObject *parent = Q_NULLPTR);
|
||||
|
||||
std::shared_ptr<const linphone::Address> getUsedSipAddress () const;
|
||||
void setUsedSipAddress (const std::shared_ptr<const linphone::Address> &address);
|
||||
|
||||
bool addOrUpdateProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig);
|
||||
|
||||
Q_INVOKABLE QVariantMap getProxyConfigDescription (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig);
|
||||
|
|
@ -97,9 +100,6 @@ private:
|
|||
|
||||
QVariantList getAccounts () const;
|
||||
|
||||
void setUsedSipAddress (const std::shared_ptr<const linphone::Address> &address);
|
||||
std::shared_ptr<const linphone::Address> getUsedSipAddress () const;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void handleRegistrationStateChanged (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue