Skip to content
Snippets Groups Projects
Select Git revision
  • de87ae908925900356bfdfcc321ddd309f40b57d
  • master default protected
  • release/202005
  • release/202001
  • release/201912
  • release/201911
  • release/releaseWindowsTestOne
  • release/windowsReleaseTest
  • release/releaseTest
  • release/releaseWindowsTest
  • release/201910
  • release/qt/201910
  • release/windows-test/201910
  • release/201908
  • release/201906
  • release/201905
  • release/201904
  • release/201903
  • release/201902
  • release/201901
  • release/201812
  • 4.0.0
  • 2.2.0
  • 2.1.0
  • 2.0.1
  • 2.0.0
  • 1.4.1
  • 1.4.0
  • 1.3.0
  • 1.2.0
  • 1.1.0
31 results

ip_utils.h

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    call.cpp 18.96 KiB
    /*
     *  Copyright (C) 2004-2019 Savoir-faire Linux Inc.
     *
     *  Author: Yan Morin <yan.morin@savoirfairelinux.com>
     *  Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com>
     *  Author: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>
     *
     *  This program is free software; you can redistribute it and/or modify
     *  it under the terms of the GNU General Public License as published by
     *  the Free Software Foundation; either version 3 of the License, or
     *  (at your option) any later version.
     *
     *  This program is distributed in the hope that it will be useful,
     *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     *  GNU General Public License for more details.
     *
     *  You should have received a copy of the GNU General Public License
     *  along with this program; if not, write to the Free Software
     *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
     */
    
    #include "call.h"
    #include "account.h"
    #include "manager.h"
    #include "audio/ringbufferpool.h"
    #include "dring/call_const.h"
    #include "client/ring_signal.h"
    #include "sip/sip_utils.h"
    #include "ip_utils.h"
    #include "array_size.h"
    #include "map_utils.h"
    #include "call_factory.h"
    #include "string_utils.h"
    #include "enumclass_utils.h"
    
    #include "errno.h"
    
    #include <stdexcept>
    #include <system_error>
    #include <algorithm>
    #include <functional>
    #include <utility>
    
    namespace jami {
    
    /// Hangup many calls with same error code, filtered by a predicate
    ///
    /// For each call pointer given by iterating on given \a callptr_list
    /// calls the unary predicate \a pred with this call pointer and hangup the call with given error
    /// code \a errcode when the predicate return true.
    /// The predicate should have <code>bool(Call*) signature</code>.
    inline void
    hangupCallsIf(const Call::SubcallSet& callptr_list, int errcode, const std::function<bool(Call*)>& pred)
    {
        std::for_each(std::begin(callptr_list), std::end(callptr_list),
                      [&](const std::shared_ptr<Call>& call_ptr) {
                          if (pred(call_ptr.get())) {
                              try {
                                  call_ptr->hangup(errcode);
                              } catch (const std::exception& e) {
                                  JAMI_ERR("[call:%s] hangup failed: %s",
                                           call_ptr->getCallId().c_str(), e.what());
                              }
                          }
                      });
    }
    
    /// Hangup many calls with same error code.
    ///