我想将sip调用添加到my quiz game。因此,我通过这种方式构建了SipHome项目:

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

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

CSipSimpleBranded
CSipSimpleCodecG729
CSipSimpleCodecPack
CSipSimpleVideoPlugin

我已经将类PluginReceiver,CaptureReceiver,PluginReceiverFfmpeg和PluginReceiverVpx从 CSipSimpleVideoPlugin 项目添加到 SipHome 项目。另外,我还将接收者的描述放入了 SipHome list 项目中:
    <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。无法创建重新邀请:媒体行(PJMEDIA_SDP_ENOFMT)中没有SDP有效负载格式[状态= 220032]

和视频不显示。

谢谢。

最佳答案

您不需要将这些接收器中的任何一个添加到主 list 中,它们仅用于检查是否已安装插件。

这是在不使用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,可能类似于: (其中“sipstack”是您的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"

10-06 09:32