Codenameone AntMedia本机接口问题
我想为Codename One实现这个AntMedia iOS和Android本机界面:Codenameone AntMedia本机接口问题,codenameone,Codenameone,我想为Codename One实现这个AntMedia iOS和Android本机界面: 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
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示例代码回答我吗?下面是SDKs文档的链接,我希望它足以回答这个问题
第二个问题是,iOS SDK是用Swift编写的:如何从必须用Objective-C编写的本机接口调用Swift代码?你能在这里用一个代码示例来回答我吗
谢谢你的支持
这是两个SDK的文档:
Android SDK文档:
iOS SDK文档:
在IDE中使用生成本机接口工具时,它会生成匹配的本机代码。该代码为每个操作系统生成本机操作系统方法,例如,在Android的情况下,
createPeer
方法将返回一个视图
因此,对于这种情况,您需要创建
org.webrtc.surfaceviewrender
的实例,并将其存储在类中(用于init的后续调用),然后从createPeer
方法返回该实例。FYI我们正在研究webrtc对Codename One的支持,因此您可能不需要这样做。我们将在一个月内推出一个测试版或SOA。对于这个问题,您是否在IDE中使用了生成本机接口功能?如果您使用它,它将生成匹配的本机代码,这将使它变得非常清晰支持多个直播提供商直接集成到Codename One中,这将是一个伟大的创新。我希望尽快尝试这种新的WebRTC支持。我真的希望如此,因为不幸的是,使用本机接口会导致我无法理解或处理的问题。谢谢