From 2d3d035312284272afb766e7361b1b1e78a3ad3f Mon Sep 17 00:00:00 2001
From: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
Date: Fri, 3 Aug 2012 11:49:33 -0400
Subject: [PATCH] * #13188: add video details to getCallDetails, if actively
 receiving video

---
 daemon/src/call.h                         |  2 +-
 daemon/src/sip/sipcall.cpp                | 10 ++++++++++
 daemon/src/sip/sipcall.h                  |  4 ++++
 daemon/src/video/video_receive_thread.cpp | 15 +++++++++++++++
 daemon/src/video/video_receive_thread.h   |  1 +
 daemon/src/video/video_rtp_session.cpp    |  7 +++++++
 daemon/src/video/video_rtp_session.h      |  1 +
 7 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/daemon/src/call.h b/daemon/src/call.h
index 7cdf74d1b4..7691da6ba0 100644
--- a/daemon/src/call.h
+++ b/daemon/src/call.h
@@ -218,7 +218,7 @@ class Call : public Recordable {
         unsigned int getLocalVideoPort();
 
         void time_stop();
-        std::map<std::string, std::string> getDetails();
+        virtual std::map<std::string, std::string> getDetails();
         static std::map<std::string, std::string> getNullDetails();
         std::map<std::string, std::string> createHistoryEntry() const;
         virtual bool setRecording();
diff --git a/daemon/src/sip/sipcall.cpp b/daemon/src/sip/sipcall.cpp
index 34c56000ec..a96cefb3f2 100644
--- a/daemon/src/sip/sipcall.cpp
+++ b/daemon/src/sip/sipcall.cpp
@@ -74,3 +74,13 @@ void SIPCall::answer()
     setConnectionState(CONNECTED);
     setState(ACTIVE);
 }
+
+std::map<std::string, std::string>
+SIPCall::getDetails()
+{
+    std::map<std::string, std::string> details(Call::getDetails());
+#ifdef SFL_VIDEO
+    videortp_.addReceivingDetails(details);
+#endif
+    return details;
+}
diff --git a/daemon/src/sip/sipcall.h b/daemon/src/sip/sipcall.h
index a5884f953d..537975fb65 100644
--- a/daemon/src/sip/sipcall.h
+++ b/daemon/src/sip/sipcall.h
@@ -106,6 +106,10 @@ class SIPCall : public Call {
         pjsip_inv_session *inv;
 
     private:
+        // override of Call::getDetails
+        std::map<std::string, std::string>
+        getDetails();
+
         virtual void answer();
 
         NON_COPYABLE(SIPCall);
diff --git a/daemon/src/video/video_receive_thread.cpp b/daemon/src/video/video_receive_thread.cpp
index 1bb48f46ca..3da361d165 100644
--- a/daemon/src/video/video_receive_thread.cpp
+++ b/daemon/src/video/video_receive_thread.cpp
@@ -316,4 +316,19 @@ void VideoReceiveThread::setRequestKeyFrameCallback(void (*cb)(const std::string
 {
     requestKeyFrameCallback_ = cb;
 }
+
+void
+VideoReceiveThread::addDetails(std::map<std::string, std::string> &details)
+{
+    if (receiving_ and dstWidth_ > 0 and dstHeight_ > 0) {
+        details["VIDEO_SHM_PATH"] = sink_.openedName();
+        std::ostringstream os;
+        os << dstWidth_;
+        details["VIDEO_WIDTH"] = os.str();
+        os.str("");
+        os << dstHeight_;
+        details["VIDEO_HEIGHT"] = os.str();
+    }
+}
+
 } // end namespace sfl_video
diff --git a/daemon/src/video/video_receive_thread.h b/daemon/src/video/video_receive_thread.h
index fccacf04ec..e4b484ab9b 100644
--- a/daemon/src/video/video_receive_thread.h
+++ b/daemon/src/video/video_receive_thread.h
@@ -92,6 +92,7 @@ class VideoReceiveThread : public ost::Thread {
 
     public:
         VideoReceiveThread(const std::string &id, const std::map<std::string, std::string> &args);
+        void addDetails(std::map<std::string, std::string> &details);
         virtual ~VideoReceiveThread();
         virtual void run();
         void setRequestKeyFrameCallback(void (*)(const std::string &));
diff --git a/daemon/src/video/video_rtp_session.cpp b/daemon/src/video/video_rtp_session.cpp
index 8c89092aba..97c655a5b7 100644
--- a/daemon/src/video/video_rtp_session.cpp
+++ b/daemon/src/video/video_rtp_session.cpp
@@ -155,4 +155,11 @@ void VideoRtpSession::forceKeyFrame()
         ERROR("Video sending thread is NULL");
 }
 
+void
+VideoRtpSession::addReceivingDetails(std::map<std::string, std::string> &details)
+{
+    if (receiveThread_.get())
+        receiveThread_->addDetails(details);
+}
+
 } // end namespace sfl_video
diff --git a/daemon/src/video/video_rtp_session.h b/daemon/src/video/video_rtp_session.h
index 2b80928cd5..748ff566ec 100644
--- a/daemon/src/video/video_rtp_session.h
+++ b/daemon/src/video/video_rtp_session.h
@@ -52,6 +52,7 @@ class VideoRtpSession {
                                unsigned int port);
         void updateSDP(const Sdp &sdp);
         void forceKeyFrame();
+        void addReceivingDetails(std::map<std::string, std::string> &details);
 
     private:
         std::tr1::shared_ptr<VideoSendThread> sendThread_;
-- 
GitLab