Android系统。 cSipSimple。如何将视频通话集成到项目中?

时间:2014-02-27 12:48:53

标签: android csip-simple

我想向my quiz game添加sip调用。所以,我通过这种方式构建了SipHome项目:

http://code.google.com/p/csipsimple/wiki/HowToBuild#Without_building_the_native_library

没关系。应用程序编译和启动。 现在我想在我的应用上添加视频通话功能。结账后(http://csipsimple.googlecode.com/svn/trunk/)我也有这个SVN依赖项:

CSipSimpleBranded
CSipSimpleCodecG729
CSipSimpleCodecPack
CSipSimpleVideoPlugin 

我已将 CSipSimpleVideoPlugin 项目中的 PluginReceiver,CaptureReceiver,PluginReceiverFfmpeg和PluginReceiverVpx 放到 SipHome 项目中。此外,我还将接收器的描述放在 SipHome 清单项目中:

    <receiver android:name=".plugins.video.PluginReceiver" >
        <intent-filter>
            <action android:name="com.csipsimple.plugins.action.REGISTER_VIDEO" />
        </intent-filter>

        <meta-data
            android:name="lib_name"
            android:value="libpj_video_android.so" />
        <!-- For now it does not matter in the future we should have one per device, codec, and converter (if needed) -->
        <meta-data
            android:name="init_factory"
            android:value="pjmedia_webrtc_vid_render_factory" />
    </receiver>

    <!--
    Receiver for video capture
    <receiver android:name=".plugins.video.CaptureReceiver" >
        <intent-filter>
            <action android:name="com.csipsimple.plugins.action.REGISTER_CAPTURE_VIDEO" />
        </intent-filter>

        <meta-data
            android:name="lib_name"
            android:value="libpj_screen_capture_android.so" />
        <meta-data
            android:name="init_factory"
            android:value="pjmedia_webrtc_vid_capture_factory" />
    </receiver>
    -->
    <receiver android:name=".plugins.video.PluginReceiverFfmpeg" >
        <intent-filter>
            <action android:name="com.csipsimple.codecs.action.REGISTER_VIDEO_CODEC" />
        </intent-filter>

        <meta-data
            android:name="lib_name"
            android:value="libpj_video_android.so" />
        <meta-data
            android:name="init_factory"
            android:value="pjmedia_codec_ffmpeg_vid_init" />
        <meta-data
            android:name="deinit_factory"
            android:value="pjmedia_codec_ffmpeg_vid_deinit" />
    </receiver>
    <receiver android:name=".plugins.video.PluginReceiverVpx" >
        <intent-filter>
            <action android:name="com.csipsimple.codecs.action.REGISTER_VIDEO_CODEC" />
        </intent-filter>

        <meta-data
            android:name="lib_name"
            android:value="libpj_vpx.so" />
        <meta-data
            android:name="init_factory"
            android:value="pjmedia_codec_vpx_init" />
        <meta-data
            android:name="deinit_factory"
            android:value="pjmedia_codec_vpx_deinit" />
    </receiver>

登录后我设置了USE_VIDEO = true标志:

prefProviderWrapper.setPreferenceBooleanValue(SipConfigManager.USE_VIDEO, true);

当我打电话给 InCallActivity 时,我看到了VideoButton,但在按下它后我在logcat中有这个:

pjsua_vid.c。无法创建re-INVITE:媒体行中没有SDP有效载荷格式(PJMEDIA_SDP_ENOFMT)[status = 220032]

并且视频没有显示。

感谢。

1 个答案:

答案 0 :(得分:-1)

您不需要将任何接收器添加到主清单中,它们仅用于检查插件是否已安装。

以下是在没有VideoPLugin的情况下使用CSipSimple进行视频通话的指南:D

修改CSipSimpleVideoPlugin构建脚本,使其将libpj_video_android.so复制到CSipSimple libs目录。 (或者每次构建时只需手动复制)。

最后要包含你需要修改PjsipService的视频库,用类似的东西替换273到307行;

String videoLibraryPath = NativeLibManager.getLibraryPath(mContext, "libpj_video_android.so");

if (!videoLibraryPath.isEmpty()) {

pj_str_t pjVideoFile = pjsua.pj_str_copy(videoLibraryPath);

// Render
dynamic_factory videoRenderFactory = csipSimpleConfig.getVideo_render_implementation();
videoRenderFactory.setInit_factory_name(pjsua.pj_str_copy("pjmedia_webrtc_vid_render_factory"));
videoRenderFactory.setShared_lib_path(pjVideoFile);

// Capture
dynamic_factory videoCaptureFactory = csipSimpleConfig.getVideo_capture_implementation();
videoCaptureFactory.setInit_factory_name(pjsua.pj_str_copy("pjmedia_webrtc_vid_capture_factory"));
videoCaptureFactory.setShared_lib_path(pjVideoFile);

// Video codecs
List<CodecInfo> availableCodecs = Lists.newArrayList(
        new CodecInfo(NativeLibManager.getLibraryPath(mContext, "libpj_video_android.so"),
                "pjmedia_codec_ffmpeg_vid_init", "pjmedia_codec_ffmpeg_vid_deinit"),

        new CodecInfo(NativeLibManager.getLibraryPath(mContext, "libpj_vpx.so"),
                "pjmedia_codec_vpx_init", "pjmedia_codec_vpx_deinit")
);

dynamic_factory[] cssCodecs = csipSimpleConfig.getExtra_vid_codecs();
dynamic_factory[] cssCodecsDestroy = csipSimpleConfig.getExtra_vid_codecs_destroy();

int videoCodecIndex = 0;
for (CodecInfo codecInfo : availableCodecs) {
    if (!TextUtils.isEmpty(codecInfo.mLibraryPath)) {
        // Create
        cssCodecs[videoCodecIndex].setShared_lib_path(pjsua.pj_str_copy(codecInfo.mLibraryPath));
        cssCodecs[videoCodecIndex].setInit_factory_name(pjsua.pj_str_copy(codecInfo.mFactoryInitFunction));
        // Destroy
        cssCodecsDestroy[videoCodecIndex].setShared_lib_path(pjsua.pj_str_copy(codecInfo.mLibraryPath));
        cssCodecsDestroy[videoCodecIndex].setInit_factory_name(pjsua.pj_str_copy(codecInfo.mFactoryDeinitFunction));
    }
    videoCodecIndex++;
}

csipSimpleConfig.setExtra_vid_codecs_cnt(videoCodecIndex);

// Converter
dynamic_factory convertImpl = csipSimpleConfig.getVid_converter();
convertImpl.setShared_lib_path(pjVideoFile);
convertImpl.setInit_factory_name(pjsua.pj_str_copy("pjmedia_libswscale_converter_init"));

NativeLibManager:

public static String getLibraryPath(Context context, String libraryName) {
    String libraryPath = "";

    PackageManager packageManager = context.getPackageManager();

    PackageInfo packageInfo = null;

    if (packageManager != null) {
        try {
            packageInfo = packageManager.getPackageInfo(context.getPackageName(), PackageManager.GET_SHARED_LIBRARY_FILES);
        } catch (NameNotFoundException e) {
            logger.error(e.getMessage());
        }
    }

    File libFile = getLibFileFromPackage(packageInfo.applicationInfo, libraryName);

    if (libFile != null) {
        libraryPath = libFile.getAbsolutePath();
    }

        return libraryPath;
    }

要修改构建脚本,您需要查看dispatch_shared_libs.sh,这可能是某些内容; (其中&#34; sipstack&#34;是你的csipsimple目录......)

move_generic_lib() {
    echo -n "Moving $1.so to $2 project ... "
    libs_files=$(ls libs/*/${1}.so 2> /dev/null | wc -l | sed -e 's/^[ \t]*//')
    if [ "$libs_files" != "0" ]; then
        for lib_folder in libs/*; do
            if [ -d ${lib_folder} ]; then
                mkdir -p ../${2}/${lib_folder};
                mv ${lib_folder}/${1}.so ../${2}/${lib_folder}/${1}.so;
            fi
        done
        echo "[OK]";
    else
        echo "[--] - plugin not built"
    fi
}

move_lib() {
    move_generic_lib libpj_${1}_codec CSipSimpleCodec${2}
}

move_lib "g7221" "Pack"
move_lib "codec2" "Pack"
move_lib "opus" "Pack"
move_lib "g726" "Pack"
move_lib "aac" "Pack"
move_lib "g729" "G729"
move_generic_lib "libcrypto" "sipstack"
move_generic_lib "libssl" "sipstack"
move_generic_lib "libpj_video_android" "sipstack"

move_generic_lib "libpj_screen_capture_android" "sipstack"
move_generic_lib "libpj_vpx" "sipstack"