Integrate Linphone in own iOS project

后端 未结 2 1373
盖世英雄少女心
盖世英雄少女心 2021-02-06 19:53

I am creating a voip call based project with Linphone and I have also successfully build and run the Linphone project and successfully run audio and video call. Now I am integra

相关标签:
2条回答
  • 2021-02-06 20:26

    With Xcode 11 using macos 10.15.6 Catalina

    Linphone SDK 4.4.0 Using Cocoapod

    https://github.com/BelledonneCommunications/linphone-sdk/blob/master/README.md

    Using a local linphone SDK Clone the linphone-sdk repository from out gitlab:

    $ git clone https://gitlab.linphone.org/BC/public/linphone-sdk.git --recursive 
    $ git submodule update --init --recursive
    

    Or

    $ git clone --recurse-submodules https://gitlab.linphone.org/BC/public/linphone-sdk.git
    

    Rebuild the project:

    PODFILE_PATH= pod install where is your build directory of the linphone-sdk project, containing the linphone-sdk.podspec file and a linphone-sdk ouptut directory comprising built frameworks and resources.

    Pod file looks like


    source "https://gitlab.linphone.org/BC/public/podspec.git"
    source "https://github.com/CocoaPods/Specs.git"
    
    def common_pods
        use_frameworks!
    
        pod 'linphone-sdk', '4.4.0'
    end
    

    Then open linphone.xcworkspace with Xcode to build and run the app.

    Linphone SDK 4.4.0 Using Compile

    $ git clone https://gitlab.linphone.org/BC/public/linphone-sdk.git -- recursive
    $ git submodule update --init --recursive
    

    Or

    $ git clone --recurse-submodules https://gitlab.linphone.org/BC/public/linphone-sdk.git
    

    Goto the build directory

    $ mkdir build && cd build
    

    ———————————

    https://gitlab.linphone.org/BC/public/linphone-cmake-builder/blob/ios-3.13.19/README.python.md

    first, install brew

    $ brew install cmake
    $ brew install yasm
    $ brew install pkg-config
    

    Install pip ->

    $ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
    $ python get-pip.py
    
    $ python -m pip install pystache //Check by $ python -m pip list
    
    $ brew install doxygen
    

    ———————————

    $ cmake .. -G Xcode -DLINPHONESDK_PLATFORM=IOS -DENABLE_G729=YES -DENABLE_G729B_CNG=YES -DENABLE_VCARD=OFF -DENABLE_ILBC=OFF -DENABLE_SILK=OFF -DENABLE_ISAC=OFF -DENABLE_MKV=OFF -DENABLE_GSM=OFF -DENABLE_DOC=OFF -DENABLE_UNIT_TESTS=OFF -DENABLE_LIME=OFF -DENABLE_GPL_THIRD_PARTIES=OFF -DENABLE_NON_FREE_CODECS=OFF
    

    Note - in this step we will also enable G729 dedec support in our linphone sdk.

    $ cmake --build . --config RelWithDebInfo
    

    The compilation process is done now need to integrate with Xcode

    Compiled Linphone SDK integrates into Xcode.

    Find compiled sdk in below directory linphone-sdk -> build -> linphone-sdk -> apple-darwin

    1. Frameworks and share folder add into xcode project, Frameworks have multiple universal architectures.
    2. Frameworks path add into framework search in build settings
    3. Every framework of Frameworks folder, should be type "embed and sign" (means embed framework.) instead of "do not embed" as default while adding into Xcode Framework setting. it's the most very important part.
    4. apple-darwin -> Tools folder have deply.sh script, copy its contents and create a new run script in "build settings" and paste in it"
    5. the tricky part is where to place the 4th point's script for upload app using archive with strip and slice. Edit Scheme -> Archive -> open dropdown -> post actions -> + to add new script -> copy and paste.

    6 (Optional). If experience script causes application crash due to fat library used our project, There is a minor change in the script, I found a solution from this URL - Errors building Xcode Project after adding in Run Script fatal error: lipo: input file

    APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
    
    find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
    do
        FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
        FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
        echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
    
    # Start of Script modify - identify if the framework is FAT. If it is, then it skips it.
        if [ ! -f "${FRAMEWORK_EXECUTABLE_PATH}" ]; then
            continue
        fi
    
        if xcrun lipo -info "${FRAMEWORK_EXECUTABLE_PATH}" | grep --silent "Non-fat"; then
            echo "Framework non-fat, skipping: $FRAMEWORK_EXECUTABLE_NAME"
            continue
        fi
    
        echo "Thinning framework $FRAMEWORK_EXECUTABLE_NAME"
    # end of Script modify
    
        EXTRACTED_ARCHS=()
    
        for ARCH in $ARCHS
        do
            echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
            lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
            EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
        done
    
        echo "Merging extracted architectures: ${ARCHS}"
        lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"
        rm "${EXTRACTED_ARCHS[@]}"
    
        echo "Replacing original executable with thinned version"
        rm "$FRAMEWORK_EXECUTABLE_PATH"
        mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"
    
    done
    
    1. If you are using pod then de integrate pod using terminal command "pod deintegrate" on your pod directory. also delete .xcworkspace file from the project.
    2. Now install pod using terminal command "pod install"

    Note: If your case was Adding script causes app crash as I mentioned in 6th point but every time adding the script, have to pod de integrate help me avoid it.

    :) Now enjoy using linphone sdk in your project.

    end of linphone sdk

    Linphone SDK Configuration in our projects.

    1. Enable Codec - To enable audio codec first enable defaultValue of g729_preference in the Audio.plist file and last step In Project -> Target -> Build Settings find "Preprocessor macros" and include HAVE_G729, it prints in sip log like Adding G729/8000 for compatibility, just in case.

    #Update - add 5th point fo compile for upload the app to the app store and G729 codec configuration.

    0 讨论(0)
  • 2021-02-06 20:44
    • Download Liblinphone iPhone SDK from the link: http://www.linphone.org/releases/ios choose latest one.
    • Move two folders (include and lib) to your project folder
    • Add paths to these folders in your project Build settings - INCLUDE folder goes to headers and LIB folder goes to libraries.
    • In General tab in Linked frameworks add all files from LIB folder
    • Download/clone the repo https://github.com/BelledonneCommunications/linphone-iphone
    • Find 4 files: LinphoneManager.h/.m and Utils.h/.m , include them in your project folder and add them to the left pane to other class files also
    • Try to compile your project - xCode will spam you with errors - this is ok.
    • You need to inspect errors and just delete all file imports causing errors (Some Linphone Address book files/ some config store files and some helpers classes that you do not need for basic use in your project (because most likely you already implemented this features in your existing project))
    • Then compile again and inspect all errors in methods. Comment delete any problematic chunks of code (there will be about 10-15 of them).

    LinphoneManager class already include many useful features - like good watch and use of linphone core with good logging and etc and etc, but not all of them (unfortunately).

    0 讨论(0)
提交回复
热议问题