基于Unity3d(U3D)平台的rtmp/rtsp直播播放端SDK

最近,好多开发者在unity3d平台面临一个问题,难于找到一个真正靠谱的低延迟rtmp播放器或rtsp播放器。

不少开发者联系我们,希望能有一个低延时的unity3d直播播放器SDK,我们封装了一下现有sdk,推送U3D安卓接口。以下是Android端的SDK接口:
    /// 
    /// Init
    /// 
    public int NT_U3D_Init()
    {
        return DANIULIVE_RETURN_OK;
    }

    /// 
    /// 开始
    /// 返回播放句柄
    /// 
    public long NT_U3D_Open()
    {
        if ( 0 != player_obj_.Call("Init", java_obj_cur_activity_) )
        {
            return 0;
        }

        return player_obj_.Call("Open");
    }

    /// 
    /// Register Game Object,用于消息传递
    /// 
    public int NT_U3D_Set_Game_Object(long handle, string gameObjectName)
    {
        return player_obj_.Call("SetGameObject", handle, gameObjectName);
    }

    /// 
    /// 设置解码方式 false 软件解码 true 硬件解码 默认为false
    /// 
    /// 
    public int NT_U3D_SetVideoDecoderMode(long handle, int isHwDecoder)
    {
        return player_obj_.Call("SetPlayerVideoHWDecoder", handle, isHwDecoder);
    }

    /// 
    /// 设置音频输出模式: if 0: 自动选择; if with 1: audiotrack模式
    /// 
    /// 
    public int NT_U3D_SetAudioOutputType(long handle, int use_audiotrack)
    {
        return player_obj_.Call("SetAudioOutputType", handle, use_audiotrack);
    }

    /// 
    /// 设置播放端缓存大小, 默认200毫秒
    /// 
    /// 
    public int NT_U3D_SetBuffer(long handle, int buffer)
    {
        return player_obj_.Call("SetBuffer", handle, buffer);
    }

    /// 
    /// 接口可实时调用:设置是否实时静音,1:静音; 0: 取消静音
    /// 
    /// 
    public int NT_U3D_SetMute(long handle, int is_mute)
    {
        return player_obj_.Call("SetMute", handle, is_mute);
    }

    /// 
    /// 设置RTSP TCP模式, 1: TCP; 0: UDP
    /// 
    /// 
    public int NT_U3D_SetRTSPTcpMode(long handle, int is_using_tcp)
    {
        return player_obj_.Call("SetRTSPTcpMode", handle, is_using_tcp);
    }

    /// 
    /// 设置超低延迟模式 false不开启 true开启 默认false
    /// 
    /// 
    public int NT_U3D_SetPlayerLowLatencyMode(long handle, int mode)
    {
        return player_obj_.Call("SetPlayerLowLatencyMode", handle, mode);
    }

    /// 
    /// 设置是否回调下载速度
    /// is_report: if 1: 上报下载速度, 0: 不上报.
    /// report_interval: 上报间隔,以秒为单位,>0.
    /// 
    /// 
    /// 
    public int NT_U3D_SetReportDownloadSpeed(long handle, int is_report, int report_interval)
    {
        return player_obj_.Call("SetReportDownloadSpeed", handle, is_report, report_interval);
    }

    /// 
    /// 设置是否需要在播放或录像过程中快照
    /// 
    /// 
    public int NT_U3D_SetSaveImageFlag(long handle, int is_save_image)
    {
        return player_obj_.Call("SetSaveImageFlag", handle, is_save_image);
    }

    /// 
    /// 播放或录像过程中快照
    /// 
    /// 
    public int NT_U3D_SaveCurImage(long handle, string imageName)
    {
        return player_obj_.Call("SaveCurImage", handle, imageName);
    }

    /// 
    /// 播放或录像过程中,快速切换url
    /// 
    /// 
    public int NT_U3D_SwitchPlaybackUrl(long handle, string uri)
    {
        return player_obj_.Call("SwitchPlaybackUrl", handle, uri);
    }

    /// 
    /// 创建录像存储路径
    /// 
    /// 
    public int NT_U3D_CreateFileDirectory(string path)
    {
        return player_obj_.Call("CreateFileDirectory", path);
    }

    /// 
    /// 设置录像存储路径
    /// 
    /// 
    public int NT_U3D_SetRecorderDirectory(long handle, string path)
    {
        return player_obj_.Call("SetRecorderDirectory", handle, path);
    }

    /// 
    /// 设置单个录像文件大小
    /// 
    /// 
    public int NT_U3D_SetRecorderFileMaxSize(long handle, int size)
    {
        return player_obj_.Call("SetRecorderFileMaxSize", handle, size);
    }

    /// 
    /// 设置播放路径
    /// 
    public int NT_U3D_SetUrl(long handle, string url)
    {
        return player_obj_.Call("SetUrl", handle, url);
    }

    /// 
    /// 开始播放
    /// 
    public int NT_U3D_StartPlay(long handle)
    {
        return player_obj_.Call("StartPlay", handle);
    }

    /// 
    /// 获取YUV数据
    /// 
    public AndroidJavaObject NT_U3D_GetVideoFrame(long handle)
    {
        return player_obj_.Call("GetVideoFrame", handle);
    }

    /// 
    /// 停止播放
    /// 
    public int NT_U3D_StopPlay(long handle)
    {
        return player_obj_.Call("StopPlay", handle);
    }

    /// 
    /// 开始录像
    /// 
    public int NT_U3D_StartRecorder(long handle)
    {
        return player_obj_.Call("StartRecorder", handle);
    }

    /// 
    /// 停止录像
    /// 
    public int NT_U3D_StopRecorder(long handle)
    {
        return player_obj_.Call("StopRecorder", handle);
    }

    /// 
    /// 关闭播放
    /// 
    public int NT_U3D_Close(long handle)
    {
        return player_obj_.Call("Close", handle);
    }

    /// 
    /// UnInit Player
    /// 
    public int NT_U3D_UnInit()
    {
        return DANIULIVE_RETURN_OK;
    }


更多信息请参考https://github.com/daniulive/SmarterStreaming


你可能感兴趣的:(直播播放器,Unity3d,rtmp直播播放器,Unity3d,rtsp直播播放器,rtmp,rtsp,直播播放器,rtmp,rtsp,rtmp直播播放器,Unity3d,rtsp直播播放器)