author | shipeng.sun <shipeng.sun@amlogic.com> | 2019-07-19 09:16:45 (GMT) |
---|---|---|
committer | Shipeng Sun <shipeng.sun@amlogic.com> | 2019-08-12 02:04:55 (GMT) |
commit | 207cf97ee887ba820dcb9c0a02c525f65b590e62 (patch) | |
tree | 036532b929b452c3dfbc05b110fad5ab53133802 | |
parent | 184399f2edb470845cbbfede84961e9eabdae99c (diff) | |
download | av-207cf97ee887ba820dcb9c0a02c525f65b590e62.zip av-207cf97ee887ba820dcb9c0a02c525f65b590e62.tar.gz av-207cf97ee887ba820dcb9c0a02c525f65b590e62.tar.bz2 |
wifi-display: Miracast screened black screen [1/1]
PD#TV-7359
Problem:
Vivo phone screened black screen through Miracast
and could not exit
Solution:
1. Sometime miracast connect the source device display
connect success but refuse sink's connect, also report
Nu-NetworkSession: writeMore on socket 319 failed w/ error
-111, modify retry max times to 5, and every times interval
to 200ms.
2. Add a check after sink and source are connect, to avoid
source dont send M1 packet in 2S lead tv black.
3. Add default send wfd_standby_resume_capability in M3
response.
Verify:
ampere
Change-Id: If0e01ca034e717f987e8646033c77826e261838c
Signed-off-by: shipeng.sun <shipeng.sun@amlogic.com>
-rw-r--r-- | libstagefright/wifi-display/sink/TunnelRenderer.h | 1 | ||||
-rw-r--r-- | libstagefright/wifi-display/sink/WifiDisplaySink.cpp | 63 | ||||
-rw-r--r-- | libstagefright/wifi-display/sink/WifiDisplaySink.h | 5 |
3 files changed, 58 insertions, 11 deletions
diff --git a/libstagefright/wifi-display/sink/TunnelRenderer.h b/libstagefright/wifi-display/sink/TunnelRenderer.h index 14be8ce..b4efac0 100644 --- a/libstagefright/wifi-display/sink/TunnelRenderer.h +++ b/libstagefright/wifi-display/sink/TunnelRenderer.h @@ -56,6 +56,7 @@ namespace android enum { kWhatNoPacketMsg, kWahtLostPacketMsg, + kWhatConnectedNoPacketCheck, }; void setIsHDCP(bool isHDCP); diff --git a/libstagefright/wifi-display/sink/WifiDisplaySink.cpp b/libstagefright/wifi-display/sink/WifiDisplaySink.cpp index 786d0d6..8e919f2 100644 --- a/libstagefright/wifi-display/sink/WifiDisplaySink.cpp +++ b/libstagefright/wifi-display/sink/WifiDisplaySink.cpp @@ -69,6 +69,7 @@ namespace android mNeedHDCP(false), mResolution(Normal), mHDCPRunning(false), + mSourceStandby(false), mIDRFrameRequestPending(false) { srand(time(0)); @@ -318,10 +319,29 @@ namespace android { ALOGI("Lost control connection."); // The control connection is dead now. - sp<AMessage> msg = new AMessage(kWhatSinkNotify, mSinkHandler); - ALOGI("post msg kWhatSinkNotify - connection reset by peer"); - msg->setString("reason", "RTSP_RESET"); - msg->post(); + if (err == -111) //"Connection refused" + { + if (mConnectionRetry++ < MAX_CONN_RETRY) + { + mNetSession->destroySession(mSessionID); + mSessionID = 0; + ALOGI("Retry rtsp connection %d", mConnectionRetry); + retryStart(200000ll); + } + else + { + sp<AMessage> msg = new AMessage(kWhatSinkNotify, mSinkHandler); + ALOGI("Post msg kWhatSinkNotify - RTSP_ERROR x2"); + msg->setString("reason", "RTSP_ERROR x2"); + msg->post(); + } + } + else { + sp<AMessage> msg = new AMessage(kWhatSinkNotify, mSinkHandler); + ALOGI("post msg kWhatSinkNotify - connection reset by peer"); + msg->setString("reason", "RTSP_RESET"); + msg->post(); + } //looper()->stop(); } break; @@ -342,7 +362,11 @@ namespace android CHECK_EQ(err, (status_t)OK); } - + //After connect we send a message for 2s to cehck have rtsp packet from source or not + //If not this will report a error + sp<AMessage> msg = new AMessage(kWhatNoPacket, this); + msg->setInt32("msg", kWhatConnectedNoPacketCheck); + msg->post(2000000); break; } @@ -461,7 +485,7 @@ namespace android break; } case kWahtLostPacketMsg: { - if (!mIDRFrameRequestPending) { + if (!mIDRFrameRequestPending && mState == PLAYING && mSourceStandby == false) { ALOGI("requesting IDR frame"); sendIDRFrameRequest(mSessionID); } @@ -475,6 +499,16 @@ namespace android } break; } + case kWhatConnectedNoPacketCheck: { + //After connect we send a message for 2s to cehck have rtsp packet from source or not + //If not this will report a error we use mNextCSeq to judge if have rtsp or not + ALOGI("kWhatConnectedNoPacketCheck mState is %d and mNextCSeq is %d ", mState, mNextCSeq); + if (mState == CONNECTED && mNextCSeq <= 1) { + sp<AMessage> msg = new AMessage(kWhatNoPacket, this); + msg->setInt32("msg", kWhatNoPacketMsg); + msg->post(); + } + } default: break; } @@ -1083,7 +1117,7 @@ namespace android "wfd_uibc_capability: none\r\n"); if (mNeedStandbyResumeCapability) - snprintf(body+ strlen(body), sizeof(body) - strlen(body), "wfd_standby_resume_capability: none\r\n"); + snprintf(body + strlen(body), sizeof(body) - strlen(body), "wfd_standby_resume_capability: supported\r\n"); if (mNeedConnectorType) snprintf(body+ strlen(body), sizeof(body) - strlen(body), @@ -1262,8 +1296,13 @@ namespace android if (strstr(content, "wfd_trigger_method: SETUP\r\n") != NULL) { AString url = AStringPrintf("rtsp://%s/wfd1.0/streamid=0", mRTSPHost.c_str()); - status_t err = sendSetup( sessionID, url.c_str()); - + status_t err = (status_t)OK; + if (mSourceStandby == true) { + err = sendPlay(sessionID, url.c_str()); + mSourceStandby = false; + } else { + err = sendSetup( sessionID, url.c_str()); + } CHECK_EQ(err, (status_t)OK); } else if (strstr(content, "wfd_trigger_method: TEARDOWN\r\n") != NULL) @@ -1279,6 +1318,12 @@ namespace android AString url = AStringPrintf("rtsp://%s/wfd1.0/streamid=0", mRTSPHost.c_str()); status_t err = sendPlay(sessionID, url.c_str()); CHECK_EQ(err, (status_t)OK); + } else if (strstr(content, "wfd_standby") != NULL) { + ALOGE("the source should be in standby now"); + //We don't do anything just wait the source exit from standby + mSourceStandby = true; + } else { + ALOGE("on setparameter receive other information"); } } diff --git a/libstagefright/wifi-display/sink/WifiDisplaySink.h b/libstagefright/wifi-display/sink/WifiDisplaySink.h index 9ada8e5..151bd6a 100644 --- a/libstagefright/wifi-display/sink/WifiDisplaySink.h +++ b/libstagefright/wifi-display/sink/WifiDisplaySink.h @@ -112,6 +112,7 @@ namespace android enum { kWhatNoPacketMsg, kWahtLostPacketMsg, + kWhatConnectedNoPacketCheck, }; enum @@ -165,7 +166,7 @@ namespace android sp<AMessage> mMsgNotify; int32_t mRTSPPort; int32_t mConnectionRetry; - #define MAX_CONN_RETRY 500 + #define MAX_CONN_RETRY 5 /*add by yalong.liu*/ bool mNeedAudioCodecs; @@ -262,7 +263,7 @@ namespace android status_t sendIDRFrameRequest(int32_t sessionID); status_t onReceiveIDRFrameRequestResponse( int32_t sessionID, const sp<ParsedMessage> &msg); - + bool mSourceStandby; DISALLOW_EVIL_CONSTRUCTORS(WifiDisplaySink); }; |