如何使用Android Pjsua 2暂停和恢复视频传输?

huangapple go评论58阅读模式
英文:

how to pause and unpause video transmission using Android Pjsua 2?

问题

我希望能够在视频通话中暂停和恢复视频传输,而不中断音频通话,使用Android的Pjsua2库。但是我目前无法理解如何将这个功能实现到示例的Android pjsua2应用程序中。非常感谢任何帮助。

我已经阅读了下面的文档,但不明白如何实施:

枚举pjsua_call_vid_strm_op 表示呼叫中的视频流操作。

PJSUA_CALL_VID_STRM_START_TRANSMIT 开始传输视频流。这将导致先前停止的流重新开始传输。
请注意,不需要向远程发送任何re-INVITE/UPDATE,因为此操作仅对本地流起作用。

PJSUA_CALL_VID_STRM_STOP_TRANSMIT 停止传输视频流。这将导致流在传输方向上暂停,从而停止发送任何视频数据包。不需要使用此操作向远程发送任何re-INVITE/UPDATE。

链接文档

英文:

I wish to pause and unpause video transmission in video call on fly without dropping Audio call using Android Pjsua2 library. But some how i am not able to understand how to implement that feature to sample android pjsua2 app. Any help would be highly appreciated.

i went through below documentation and not able to understand ..how to implement it

> enum pjsua_call_vid_strm_op This enumeration represents video stream
> operation on a call.
>
>
>
>
> PJSUA_CALL_VID_STRM_START_TRANSMIT Start transmitting video stream.
> This will cause previously stopped stream to start transmitting again.
> Note that no re-INVITE/UPDATE is to be transmitted to remote since
> this operation only operates on local stream.
>
> PJSUA_CALL_VID_STRM_STOP_TRANSMIT Stop transmitting video stream.
> This will cause the stream to be paused in TX direction, causing it to
> stop sending any video packets. No re-INVITE/UPDATE is to be
> transmitted to remote with this operation.

link documentation

答案1

得分: 1

考虑以下代码:

fun strmStopTransmit() {
    if (manager.isCaptureActive(camDevId)) {
        val callVidPrm = CallVidSetStreamParam()
        callVidPrm.setCapDev(camDevId)
        call.vidSetStream(pjsua_call_vid_strm_op.PJSUA_CALL_VID_STRM_STOP_TRANSMIT, callVidPrm)
    }
}

其中 managerpj::VidDevManager 的实例(链接)(可以从 pj::Endpoint 获取该实例)而 callpj::Call 的实例(链接)。

逆函数的实现(恢复传输)是显而易见的。

祝好运!

英文:

Consider this code:

fun strmStopTransmit() {
    if (manager.isCaptureActive(camDevId)) {
        val callVidPrm = CallVidSetStreamParam()
        callVidPrm.setCapDev(camDevId)
        call.vidSetStream(pjsua_call_vid_strm_op.PJSUA_CALL_VID_STRM_STOP_TRANSMIT, callVidPrm)
    }
}

Where manager is instance of pj::VidDevManager (link) (you can get it from pj::Endpoint (link)) and call is instance of pj::Call (link).

The implementation of the inverse function (resuming transmission) is obvious.

Good luck!

答案2

得分: 0

这份文件太冗长,不够合适。我已经经历过同样的问题。

以下内容可能对你有帮助:

SipManager.getInstance()?.activeCalls?.get(callId)?.mVideoPreview?.stop()

在这里,activeCallsMyCall 的实例。

英文:

This document is too lengthy and not proper. I have been went through the same problem.

The following might help you:

SipManager.getInstance()?.activeCalls?.get(callId)?.mVideoPreview?.stop()

Here, activeCalls is instance of MyCall.

答案3

得分: 0

try {
    CallInfo ci = currentCall.getInfo();
    CallMediaInfoVector callMediaInfoVector = ci.getMedia();
    for (int i = 0; i < callMediaInfoVector.size(); i++) {
        CallMediaInfo callMediaInfo = callMediaInfoVector.get(i);
        if (ep.vidDevManager().isCaptureActive(callMediaInfo.getVideoCapDev())) {
            CallVidSetStreamParam callVidPrm = new CallVidSetStreamParam();
            callVidPrm.setCapDev(callMediaInfo.getVideoCapDev());
            try {
                if (!isVideoDisable) {
                    currentCall.vidSetStream(pjsua_call_vid_strm_op.PJSUA_CALL_VID_STRM_STOP_TRANSMIT, callVidPrm);
                    isVideoDisable = true;
                } else {
                    currentCall.vidSetStream(pjsua_call_vid_strm_op.PJSUA_CALL_VID_STRM_START_TRANSMIT, callVidPrm);
                    isVideoDisable = false;
                }
            } catch (Exception e) {
                cLogE(TAG, "exception");
            }
        }
    }
} catch (Exception e) {
    cLogE(TAG, "exception");
}
英文:
try {
    CallInfo ci = currentCall.getInfo();
    CallMediaInfoVector callMediaInfoVector = ci.getMedia();
    for (int i = 0; i &lt; callMediaInfoVector.size(); i++) {
        CallMediaInfo callMediaInfo = callMediaInfoVector.get(i);
        if (ep.vidDevManager().isCaptureActive(callMediaInfo.getVideoCapDev())) {
            CallVidSetStreamParam callVidPrm = new CallVidSetStreamParam();
            callVidPrm.setCapDev(callMediaInfo.getVideoCapDev());
            try {
                if(!isVideoDisable){
                    currentCall.vidSetStream(pjsua_call_vid_strm_op.PJSUA_CALL_VID_STRM_STOP_TRANSMIT, callVidPrm);
                    isVideoDisable = true;
                }else {
                    currentCall.vidSetStream(pjsua_call_vid_strm_op.PJSUA_CALL_VID_STRM_START_TRANSMIT, callVidPrm);
                    isVideoDisable = false;
                }
            } catch (Exception e) {
                cLogE(TAG,&quot;exception&quot;);
            }
        }
    }
} catch (Exception e) {
    cLogE(TAG,&quot;exception&quot;);
}

huangapple
  • 本文由 发表于 2020年9月2日 17:35:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/63702759.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定