首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AntMedia本机接口问题

AntMedia本机接口问题
EN

Stack Overflow用户
提问于 2020-07-05 16:02:03
回答 1查看 144关注 0票数 1

我想为Codename One实现这个AntMedia iOS和Android原生接口:

代码语言:javascript
复制
import com.codename1.system.NativeInterface;
import com.codename1.ui.PeerComponent;

/**
 * @deprecated Native Interface, deprecated because you normally should use the
 * public API in the AntMediaClient class.
 */
public interface AntMediaNative extends NativeInterface {

    /**
     * Initializes the connection.
     *
     * @param serverURL is WebSocket url to connect (wss://...)
     * @param streamId is the stream id in the server to process
     * @param mode true means MODE_PUBLISH, false means MODE_PLAY
     * @param tokenId is one time token string
     * @return PeerComponent
     */
    public PeerComponent createPeer(String serverURL, String streamId, boolean mode, String tokenId);

    /**
     * Starts the streaming according to the mode.
     */
    public void startStream();

    /**
     * Stops the streaming.
     */
    public void stopStream();

    /**
     * Switches the cameras.
     */
    public void switchCamera();

    /**
     * Toggle microphone.
     *
     * @return microphone current status.
     */
    public boolean toggleMic();

    /**
     * Stops the video source.
     */
    public void stopVideoSource();

    /**
     * Starts or restarts the video source.
     */
    public void startVideoSource();

    /**
     * Get the error.
     *
     * @return error or null if not.
     */
    public String getError();

    /**
     * Camera open order.By default front camera is attempted to be opened at
     * first, if it is set to false, another camera that is not front will be
     * tried to be open.
     *
     * @param openFrontCamera if it is true, front camera will tried to be
     * opened, if it is false, another camera that is not front will be tried to
     * be opened
     */
    public void setOpenFrontCamera(boolean openFrontCamera);
}

我需要两个具体问题的帮助。

第一个问题是如何获取观看直播的PeerComponent。我不明白在这种情况下,我必须在原生Android和iOS代码中做什么。你能用一个返回PeerComponent的iOS和Android示例代码来回答我吗?下面是SDK文档的链接,我希望它足以回答这个问题。

第二个问题是iOS的开发工具包是用Swift编写的:我如何从必须用Objective-C编写的本机接口调用Swift代码?你能在这里用一个代码例子来回答我吗?

谢谢您一直鼓励我。

以下是两个SDK的文档:

Android SDK文档:https://github.com/ant-media/Ant-Media-Server/wiki/WebRTC-Android-SDK-Documentation

iOS开发工具包文档:https://github.com/ant-media/Ant-Media-Server/wiki/WebRTC-iOS-SDK-Documentation

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-07-06 10:03:00

当您在IDE中使用Generate Native Interface工具时,它会生成匹配的本机代码。该代码为每个操作系统生成本机OS方法,例如,在安卓系统中,createPeer方法将返回一个View

因此,对于本例,您需要创建一个org.webrtc.SurfaceViewRenderer实例并将其存储在类中(用于对init的后续调用),然后从createPeer方法返回该实例。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62738263

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档