From efcd6fa48e249924ae51dfa9b60eaf090ae2f8ff Mon Sep 17 00:00:00 2001
From: Ming Rui Zhang <mingrui.zhang@savoirfairelinux.com>
Date: Tue, 20 Aug 2019 13:44:42 -0400
Subject: [PATCH] avmodel: add API to set/get the current viewed video capture
 device

- distinguish default device and current viewed device

Change-Id: I174fd517a5deddd684e85f37f47c3ef938b3aeba
---
 src/api/avmodel.h | 17 +++++++++++++++++
 src/avmodel.cpp   | 19 +++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/src/api/avmodel.h b/src/api/avmodel.h
index 4c0d2f17..c8fdb5bd 100644
--- a/src/api/avmodel.h
+++ b/src/api/avmodel.h
@@ -285,6 +285,23 @@ public:
      */
     void useAVFrame(bool useAVFrame);
 
+     /**
+     * set current using device
+     * @ param device name
+     */
+    void setCurrentVideoCaptureDevice(std::string &currentVideoCaptureDevice);
+
+     /**
+     * set current using device
+     * @ return current using device name
+     */
+    std::string getCurrentVideoCaptureDevice() const;
+
+     /**
+     * clear current using device
+     */
+    void clearCurrentVideoCaptureDevice();
+
 Q_SIGNALS:
     /**
      * Emitted when a renderer is started
diff --git a/src/avmodel.cpp b/src/avmodel.cpp
index f30a727c..5bd2bbfb 100644
--- a/src/avmodel.cpp
+++ b/src/avmodel.cpp
@@ -65,6 +65,7 @@ public:
     // store if a renderers is for a finished call
     std::map<std::string, bool> finishedRenderers_;
     bool useAVFrame_ = false;
+    std::string currentVideoCaptureDevice_ {};
 
 #ifndef ENABLE_LIBWRAP
     // TODO: Init Video Renderers from daemon (see: https://git.ring.cx/savoirfairelinux/ring-daemon/issues/59)
@@ -611,6 +612,24 @@ AVModel::getCurrentRenderedDevice(const std::string& call_id) const
     return result;
 }
 
+void
+AVModel::setCurrentVideoCaptureDevice(std::string &currentVideoCaptureDevice)
+{
+    pimpl_->currentVideoCaptureDevice_ = currentVideoCaptureDevice;
+}
+
+std::string
+AVModel::getCurrentVideoCaptureDevice() const
+{
+    return pimpl_->currentVideoCaptureDevice_;
+}
+
+void
+AVModel::clearCurrentVideoCaptureDevice()
+{
+    pimpl_->currentVideoCaptureDevice_.clear();
+}
+
 AVModelPimpl::AVModelPimpl(AVModel& linked, const CallbacksHandler& callbacksHandler)
 : linked_(linked)
 , callbacksHandler(callbacksHandler)
-- 
GitLab