Skip to content
Snippets Groups Projects
Select Git revision
  • d1d064d8ad12d48f4d6955586d4e7af99bebaeab
  • 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

data_transfer.h

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    iaxcall.cpp 3.66 KiB
    /*
     *  Copyright (C) 2006-2007 Savoir-Faire Linux inc.
     *  Author: Alexandre Bourget <alexandre.bourget@savoirfairelinux.com>
     *  Author: Yan Morin <yan.morin@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., 675 Mass Ave, Cambridge, MA 02139, USA.
     */
    
    #include "iaxcall.h"
    #include "global.h" // for _debug
    
    IAXCall::IAXCall (const CallID& id, Call::CallType type) : Call (id, type), _session (NULL)
    {
    }
    
    IAXCall::~IAXCall()
    {
        _session = NULL; // just to be sure to don't have unknown pointer, do not delete it!
    }
    
    void
    IAXCall::setFormat (int format)
    {
        _format = format;
    
        switch (format) {
    
            case AST_FORMAT_ULAW:
                setAudioCodec (PAYLOAD_CODEC_ULAW);
                break;
    
            case AST_FORMAT_GSM:
                setAudioCodec (PAYLOAD_CODEC_GSM);
                break;
    
            case AST_FORMAT_ALAW:
                setAudioCodec (PAYLOAD_CODEC_ALAW);
                break;
    
            case AST_FORMAT_ILBC:
                setAudioCodec (PAYLOAD_CODEC_ILBC_20);
                break;
    
            case AST_FORMAT_SPEEX:
                setAudioCodec (PAYLOAD_CODEC_SPEEX_8000);
                break;
    
            default:
                setAudioCodec ( (AudioCodecType) -1);
                break;
        }
    }
    
    
    int
    IAXCall::getSupportedFormat()
    {
        CodecOrder map;
        int format = 0;
        unsigned int iter;
    
        map = getCodecMap().getActiveCodecs();
    
        for (iter=0 ; iter < map.size() ; iter++) {
            switch (map[iter]) {
    
                case PAYLOAD_CODEC_ULAW:
                    format |= AST_FORMAT_ULAW;
                    break;
    
                case PAYLOAD_CODEC_GSM:
                    format |= AST_FORMAT_GSM;
                    break;
    
                case PAYLOAD_CODEC_ALAW:
                    format |= AST_FORMAT_ALAW;
                    break;
    
                case PAYLOAD_CODEC_ILBC_20:
                    format |= AST_FORMAT_ILBC;
                    break;
    
                case PAYLOAD_CODEC_SPEEX_8000:
                    format |= AST_FORMAT_SPEEX;
                    break;
    
                default:
                    break;
            }
        }
    
        return format;
    
    }
    
    int
    IAXCall::getFirstMatchingFormat (int needles)
    {
        CodecOrder map = getCodecMap().getActiveCodecs();
        int format = 0;
        unsigned int iter;
    
        for (iter=0 ; iter < map.size() ; iter++) {
            switch (map[iter]) {
    
                case PAYLOAD_CODEC_ULAW:
                    format = AST_FORMAT_ULAW;
                    break;
    
                case PAYLOAD_CODEC_GSM:
                    format = AST_FORMAT_GSM;
                    break;
    
                case PAYLOAD_CODEC_ALAW:
                    format = AST_FORMAT_ALAW;
                    break;
    
                case PAYLOAD_CODEC_ILBC_20:
                    format = AST_FORMAT_ILBC;
                    break;
    
                case PAYLOAD_CODEC_SPEEX_8000:
                    format = AST_FORMAT_SPEEX;
                    break;
    
                default:
                    break;
            }
    
            // Return the first that matches
            if (format & needles)
                return format;
    
        }
    
        return 0;
    }
    
    CodecDescriptor& IAXCall::getCodecMap()
    {
        return _codecMap;
    }
    
    AudioCodecType IAXCall::getAudioCodec()
    {
        return _audioCodec;
    }