diff --git a/src/api/avmodel.h b/src/api/avmodel.h index 64a00897605a49585dd1948f0be2f4dad2b34ca1..913fa15dcb1adddd3565aff16620e6789b8890c4 100644 --- a/src/api/avmodel.h +++ b/src/api/avmodel.h @@ -194,7 +194,7 @@ public: * Start a local recorder and return it path. * @param audioOnly */ - Q_INVOKABLE QString startLocalRecorder(const bool& audioOnly) const; + Q_INVOKABLE QString startLocalMediaRecorder(const QString& videoInputId) const; /** * Get the current recording path * @return recording path @@ -237,12 +237,15 @@ public: Q_INVOKABLE void setRecordQuality(const int& quality) const; /** * Start preview renderer. This will start the camera + * @param resource + * @return sinkId */ - Q_INVOKABLE void startPreview(); + Q_INVOKABLE QString startPreview(const QString& resource); /** * Stop preview renderer and the camera. + * @param resource */ - Q_INVOKABLE void stopPreview(); + Q_INVOKABLE void stopPreview(const QString& resource); /** * Get a renderer from a call * @param id the callid or "local" diff --git a/src/avmodel.cpp b/src/avmodel.cpp index b70cbca63e252a5b10f7ca53721388e78564c77f..27c16b30e37b7d95d36447e9c5d4abd61c303158 100644 --- a/src/avmodel.cpp +++ b/src/avmodel.cpp @@ -292,8 +292,8 @@ AVModel::setDeviceSettings(video::Settings& settings) if (pimpl_->renderers_[video::PREVIEW_RENDERER_ID]) { if (pimpl_->renderers_[video::PREVIEW_RENDERER_ID]->isRendering() && pimpl_->renderers_.size() == 1) { - stopPreview(); - startPreview(); + stopPreview(video::PREVIEW_RENDERER_ID); + startPreview(video::PREVIEW_RENDERER_ID); } } } @@ -452,10 +452,10 @@ AVModel::stopLocalRecorder(const QString& path) const } QString -AVModel::startLocalRecorder(const bool& audioOnly) const +AVModel::startLocalMediaRecorder(const QString& videoInputId) const { const QString path = pimpl_->getRecordingPath(); - const QString finalPath = VideoManager::instance().startLocalRecorder(audioOnly, path); + const QString finalPath = VideoManager::instance().startLocalMediaRecorder(videoInputId, path); return finalPath; } @@ -516,16 +516,16 @@ AVModel::useAVFrame(bool useAVFrame) } } -void -AVModel::startPreview() +QString +AVModel::startPreview(const QString& resource) { - VideoManager::instance().startCamera(); + return QString(VideoManager::instance().openVideoInput(resource.toStdString()).c_str()); } void -AVModel::stopPreview() +AVModel::stopPreview(const QString& resource) { - VideoManager::instance().stopCamera(); + VideoManager::instance().closeVideoInput(resource.toStdString()); } const video::Renderer& @@ -549,7 +549,7 @@ AVModel::setInputFile(const QString& uri, const QString& callId) .arg(QUrl(uri).toLocalFile()) : DRing::Media::VideoProtocolPrefix::NONE; if (callId.isEmpty()) { - VideoManager::instance().switchInput(resource); + VideoManager::instance().openVideoInput(resource.toStdString()); } else { CallManager::instance().switchInput(callId, resource); } @@ -593,7 +593,7 @@ AVModel::switchInputTo(const QString& id, const QString& callId) resource = QString(DRing::Media::VideoProtocolPrefix::NONE); } if (callId.isEmpty()) { - VideoManager::instance().switchInput(resource); + VideoManager::instance().openVideoInput(resource.toStdString()); } else { CallManager::instance().switchInput(callId, resource); } diff --git a/src/qtwrapper/videomanager_wrap.h b/src/qtwrapper/videomanager_wrap.h index 4e5adf81888ceaf0c9175e1c0ac7c541b870938f..26c63960c66b1c65491c2dcdb16e75bf03446143 100644 --- a/src/qtwrapper/videomanager_wrap.h +++ b/src/qtwrapper/videomanager_wrap.h @@ -162,17 +162,17 @@ public Q_SLOTS: // METHODS #endif } - void startCamera() + std::string openVideoInput(const std::string& resource) { #ifdef ENABLE_VIDEO - DRing::startCamera(); + return DRing::openVideoInput(resource); #endif } - void stopCamera() + void closeVideoInput(const std::string& resource) { #ifdef ENABLE_VIDEO - DRing::stopCamera(); + DRing::closeVideoInput(resource); #endif } @@ -180,16 +180,6 @@ public Q_SLOTS: // METHODS void stopAudioDevice() { DRing::stopAudioDevice(); } - bool switchInput(const QString& resource) - { -#ifdef ENABLE_VIDEO - return DRing::switchInput(resource.toStdString()); -#else - Q_UNUSED(resource) - return false; -#endif - } - void registerSinkTarget(const QString& sinkID, const DRing::SinkTarget& target) { #ifdef ENABLE_VIDEO @@ -219,9 +209,10 @@ public Q_SLOTS: // METHODS void stopLocalRecorder(const QString& path) { DRing::stopLocalRecorder(path.toStdString()); } - QString startLocalRecorder(bool audioOnly, const QString& path) + QString startLocalMediaRecorder(const QString& videoInputId, const QString& path) { - return QString::fromStdString(DRing::startLocalRecorder(audioOnly, path.toStdString())); + return QString::fromStdString( + DRing::startLocalMediaRecorder(videoInputId.toStdString(), path.toStdString())); } MapStringString getRenderer(const QString& id)