From fe186beeb8a8c914cd3db90c66f6ebefe6dfe539 Mon Sep 17 00:00:00 2001
From: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>
Date: Tue, 28 Mar 2017 19:46:27 -0400
Subject: [PATCH] call: move media related API in dedicated header section

Media API are in refactoring.
To help to this huge task this patch moves all media related
API declaration from Call class header into a dedicated section.
It's help maintainance and new insertion, then it help to detect
what is wrong with current media design.

Change-Id: I4f65436112337b4a44eea37680d56e0fb4f5696d
---
 src/call.h | 106 +++++++++++++++++++++++++++--------------------------
 1 file changed, 54 insertions(+), 52 deletions(-)

diff --git a/src/call.h b/src/call.h
index b44843a049..463cd9a21b 100644
--- a/src/call.h
+++ b/src/call.h
@@ -195,39 +195,9 @@ class Call : public Recordable, public std::enable_shared_from_this<Call> {
             isIPToIP_ = IPToIP;
         }
 
-        /**
-         * Set local audio port, as seen by me [not protected]
-         * @param port  The local audio port
-         */
-        void setLocalAudioPort(unsigned int port) {
-            localAudioPort_ = port;
-        }
-
-        /**
-         * Set local video port, as seen by me [not protected]
-         * @param port  The local video port
-         */
-        void setLocalVideoPort(unsigned int port)  {
-            localVideoPort_ = port;
-        }
-
-        /**
-         * Return port used locally (for my machine) [mutex protected]
-         * @return unsigned int  The local audio port
-         */
-        unsigned int getLocalAudioPort() const;
-
-        /**
-         * Return port used locally (for my machine) [mutex protected]
-         * @return unsigned int  The local video port
-         */
-        unsigned int getLocalVideoPort() const;
-
         virtual std::map<std::string, std::string> getDetails() const;
         static std::map<std::string, std::string> getNullDetails();
 
-        virtual bool toggleRecording();
-
         /**
          * Answer the call
          */
@@ -239,8 +209,6 @@ class Call : public Recordable, public std::enable_shared_from_this<Call> {
          */
         virtual void hangup(int reason) = 0;
 
-        virtual void switchInput(const std::string&) {};
-
         /**
          * Refuse incoming call
          */
@@ -271,6 +239,59 @@ class Call : public Recordable, public std::enable_shared_from_this<Call> {
          */
         virtual bool offhold() = 0;
 
+        /**
+         * Peer has hung up a call
+         */
+        virtual void peerHungup();
+
+        virtual void removeCall();
+
+        using StateListener = std::function<void(CallState, int)>;
+
+        template<class T>
+        void addStateListener(T&& list) {
+            stateChangedListeners_.emplace_back(std::forward<T>(list));
+        }
+
+        /**
+         * Attach subcall to this instance.
+         * If this subcall is answered, this subcall and this instance will be merged using merge().
+         */
+        void addSubCall(Call& call);
+
+    public: // media management
+        /**
+         * Set local audio port, as seen by me [not protected]
+         * @param port  The local audio port
+         */
+        void setLocalAudioPort(unsigned int port) {
+            localAudioPort_ = port;
+        }
+
+        /**
+         * Set local video port, as seen by me [not protected]
+         * @param port  The local video port
+         */
+        void setLocalVideoPort(unsigned int port)  {
+            localVideoPort_ = port;
+        }
+
+        /**
+         * Return port used locally (for my machine) [mutex protected]
+         * @return unsigned int  The local audio port
+         */
+        unsigned int getLocalAudioPort() const;
+
+        /**
+         * Return port used locally (for my machine) [mutex protected]
+         * @return unsigned int  The local video port
+         */
+        unsigned int getLocalVideoPort() const;
+
+        virtual bool toggleRecording();
+
+        virtual void switchInput(const std::string&) {};
+
         /**
          * mute/unmute a media of a call
          * @param mediaType type of media
@@ -278,11 +299,6 @@ class Call : public Recordable, public std::enable_shared_from_this<Call> {
          */
         virtual void muteMedia(const std::string& mediaType, bool isMuted)  = 0;
 
-        /**
-         * Peer has hung up a call
-         */
-        virtual void peerHungup();
-
         /**
          * Send DTMF
          * @param code  The char code
@@ -301,8 +317,6 @@ class Call : public Recordable, public std::enable_shared_from_this<Call> {
 
         void onTextMessage(std::map<std::string, std::string>&& messages);
 
-        virtual void removeCall();
-
         virtual bool initIceTransport(bool master, unsigned channel_num=4);
 
         bool isIceRunning() const;
@@ -318,20 +332,8 @@ class Call : public Recordable, public std::enable_shared_from_this<Call> {
         }
 
         virtual void restartMediaSender() = 0;
-        virtual void restartMediaReceiver() = 0;
 
-        using StateListener = std::function<void(CallState, int)>;
-
-        template<class T>
-        void addStateListener(T&& list) {
-            stateChangedListeners_.emplace_back(std::forward<T>(list));
-        }
-
-        /**
-         * Attach subcall to this instance.
-         * If this subcall is answered, this subcall and this instance will be merged using merge().
-         */
-        void addSubCall(Call& call);
+        virtual void restartMediaReceiver() = 0;
 
     protected:
         virtual void merge(Call& scall);
-- 
GitLab