diff --git a/src/app/videodevices.cpp b/src/app/videodevices.cpp index ff962588e4a4fbd1ebccf67ab94d8b18c120602c..d0ab7cc4e71193198276e899c1b5c67fe122cb0c 100644 --- a/src/app/videodevices.cpp +++ b/src/app/videodevices.cpp @@ -271,7 +271,7 @@ VideoDevices::setDefaultDevice(int index, bool useSourceModel) lrcInstance_->avModel().setDefaultDevice(deviceId); if (!callId.isEmpty()) - lrcInstance_->getCurrentCallModel()->switchInputTo(deviceId, callId); + lrcInstance_->getCurrentCallModel()->replaceDefaultCamera(callId, deviceId); updateData(); } @@ -455,37 +455,18 @@ VideoDevices::onVideoDeviceEvent() deviceEvent = DeviceEvent::Removed; } - auto cb = [this, currentDeviceListSize, deviceEvent, defaultDevice, callId] { - auto& avModel = lrcInstance_->avModel(); - auto* callModel = lrcInstance_->getCurrentCallModel(); - if (currentDeviceListSize == 0) { - callModel->switchInputTo({}, callId); - avModel.stopPreview(this->getDefaultDevice()); - } else if (deviceEvent == DeviceEvent::Removed) { - callModel->switchInputTo(defaultDevice, callId); - } - - updateData(); - Q_EMIT deviceListChanged(currentDeviceListSize); - }; - if (deviceEvent == DeviceEvent::Added) { updateData(); Q_EMIT deviceListChanged(currentDeviceListSize); } else if (deviceEvent == DeviceEvent::FirstDevice) { updateData(); - if (callId.isEmpty()) { + if (callId.isEmpty()) Q_EMIT deviceAvailable(); - } else { - callModel->switchInputTo(defaultDevice, callId); - } Q_EMIT deviceListChanged(currentDeviceListSize); } else if (deviceOpen_) { updateData(); - } else { - cb(); } } diff --git a/src/libclient/api/callmodel.h b/src/libclient/api/callmodel.h index 529e95655775bc45df47eae2821cb0874d12273b..4b152bf3d943b7264b4b21bad1334035b5aeefa6 100644 --- a/src/libclient/api/callmodel.h +++ b/src/libclient/api/callmodel.h @@ -374,22 +374,7 @@ public: */ video::RenderedDevice getCurrentRenderedDevice(const QString& call_id) const; - /** - * @deprecated - * Render a file to the call id specified - * @param uri the path of the file - * @param callId - * @note callId can be omitted to switch the input of the local recorder - */ - void setInputFile(const QString& uri, const QString& callId = {}); - /** - * Change the current device rendered for the call id specified - * @param id of the camera - * @param callId - * @note renders a black frame if device not found or empty - * @note callId can be omitted to switch the input of the local recorder - */ - void switchInputTo(const QString& id, const QString& callId = {}); + void replaceDefaultCamera(const QString& callId, const QString& deviceId); /** * Get the current display resource string * @param idx of the display @@ -404,18 +389,8 @@ public: * @param windowId */ QString getDisplay(const QString& windowId); - /** - * @deprecated - * Render the current display to the call id specified - * @param idx of the display - * @param x top left of the area - * @param y top up of the area - * @param w width of the area - * @param h height of the area - * @param callId - * @note callId can be omitted to switch the input of the local recorder - */ - void setDisplay(int idx, int x, int y, int w, int h, const QString& callId = {}); + + void emplaceConversationConference(const QString& callId); Q_SIGNALS: /** diff --git a/src/libclient/callmodel.cpp b/src/libclient/callmodel.cpp index 176319985487a97992fa102110fed59d43275cb5..15985e6488f62e77c8cb4d86f17e381ebca4011d 100644 --- a/src/libclient/callmodel.cpp +++ b/src/libclient/callmodel.cpp @@ -419,6 +419,38 @@ CallModel::muteMedia(const QString& callId, const QString& label, bool mute) CallManager::instance().requestMediaChange(owner.id, callId, proposedList); } +void +CallModel::replaceDefaultCamera(const QString& callId, const QString& deviceId) +{ + auto& callInfo = pimpl_->calls[callId]; + if (!callInfo) + return; + + VectorMapStringString proposedList = callInfo->mediaList; + QString oldPreview, newPreview; + for (auto& media : proposedList) { + if (media[MediaAttributeKey::MEDIA_TYPE] == MediaAttributeValue::VIDEO + && media[MediaAttributeKey::SOURCE].startsWith( + DRing::Media::VideoProtocolPrefix::CAMERA)) { + oldPreview = media[MediaAttributeKey::SOURCE]; + QString resource = QString("%1%2%3") + .arg(DRing::Media::VideoProtocolPrefix::CAMERA) + .arg(DRing::Media::VideoProtocolPrefix::SEPARATOR) + .arg(deviceId); + media[MediaAttributeKey::SOURCE] = resource; + newPreview = resource; + break; + } + } + + if (!newPreview.isEmpty()) { + pimpl_->lrc.getAVModel().stopPreview(oldPreview); + pimpl_->lrc.getAVModel().startPreview(newPreview); + } + + CallManager::instance().requestMediaChange(owner.id, callId, proposedList); +} + void CallModel::addMedia(const QString& callId, const QString& source, MediaRequestType type, bool mute) { @@ -840,22 +872,6 @@ CallModel::getCurrentRenderedDevice(const QString& call_id) const return result; } -void -CallModel::setInputFile(const QString& uri, const QString& callId) -{ - QString sep = DRing::Media::VideoProtocolPrefix::SEPARATOR; - auto resource = !uri.isEmpty() ? QString("%1%2%3") - .arg(DRing::Media::VideoProtocolPrefix::FILE) - .arg(sep) - .arg(QUrl(uri).toLocalFile()) - : DRing::Media::VideoProtocolPrefix::NONE; - if (callId.isEmpty()) { - VideoManager::instance().openVideoInput(resource); - } else { - CallManager::instance().switchInput(owner.id, callId, resource); - } -} - QString CallModel::getDisplay(int idx, int x, int y, int w, int h) { @@ -880,36 +896,6 @@ CallModel::getDisplay(const QString& windowId) .arg(windowId); } -void -CallModel::setDisplay(int idx, int x, int y, int w, int h, const QString& callId) -{ - auto resource = getDisplay(idx, x, y, w, h); - if (callId.isEmpty()) { - VideoManager::instance().openVideoInput(resource); - } else { - CallManager::instance().switchInput(owner.id, callId, resource); - } -} - -void -CallModel::switchInputTo(const QString& id, const QString& callId) -{ - QString resource; - auto devices = pimpl_->lrc.getAVModel().getDevices(); - auto deviceAvailable = std::find(std::begin(devices), std::end(devices), id); - if (deviceAvailable != devices.end()) { - QString sep = DRing::Media::VideoProtocolPrefix::SEPARATOR; - resource = QString("%1%2%3").arg(DRing::Media::VideoProtocolPrefix::CAMERA).arg(sep).arg(id); - } else { - resource = QString(DRing::Media::VideoProtocolPrefix::NONE); - } - if (callId.isEmpty()) { - VideoManager::instance().openVideoInput(resource); - } else { - CallManager::instance().switchInput(owner.id, callId, resource); - } -} - CallModelPimpl::CallModelPimpl(const CallModel& linked, Lrc& lrc, const CallbacksHandler& callbacksHandler,