summaryrefslogtreecommitdiff
authorshipeng.sun <shipeng.sun@amlogic.com>2019-03-20 06:12:09 (GMT)
committer Shipeng Sun <shipeng.sun@amlogic.com>2019-03-20 06:24:21 (GMT)
commitab4707ffe7f3d487d5bd4e89b3eff3cf1101eb23 (patch)
tree9922be09920969d4340256ba6aa5737dc9e15ce9
parent78b47f822ff413783224d7a9437858555c47b78a (diff)
downloadav-ab4707ffe7f3d487d5bd4e89b3eff3cf1101eb23.zip
av-ab4707ffe7f3d487d5bd4e89b3eff3cf1101eb23.tar.gz
av-ab4707ffe7f3d487d5bd4e89b3eff3cf1101eb23.tar.bz2
libstagefright: Add request IDR frame when lost packet [1/1]
PD#SWPL-2139 Problem: Add request IDR frame when lost packet Solution: Add request IDR frame when lost packet Verify: Verify on darwin Change-Id: I856c5f6682e567bf6a24a7a234ec98adb0056ffb Signed-off-by: shipeng.sun <shipeng.sun@amlogic.com>
Diffstat
-rw-r--r--libstagefright/wifi-display/sink/RTPSink.cpp6
-rw-r--r--libstagefright/wifi-display/sink/RTPSink.h4
-rw-r--r--libstagefright/wifi-display/sink/TunnelRenderer.cpp14
-rw-r--r--libstagefright/wifi-display/sink/TunnelRenderer.h10
-rw-r--r--libstagefright/wifi-display/sink/WifiDisplaySink.cpp67
-rw-r--r--libstagefright/wifi-display/sink/WifiDisplaySink.h4
6 files changed, 80 insertions, 25 deletions
diff --git a/libstagefright/wifi-display/sink/RTPSink.cpp b/libstagefright/wifi-display/sink/RTPSink.cpp
index 4da179e..0fd0878 100644
--- a/libstagefright/wifi-display/sink/RTPSink.cpp
+++ b/libstagefright/wifi-display/sink/RTPSink.cpp
@@ -273,7 +273,7 @@ namespace android
RTPSink::RTPSink(
const sp<AmANetworkSession> &netSession,
const sp<IGraphicBufferProducer> &bufferProducer,
- const sp<AMessage> &stopNotify)
+ const sp<AMessage> &msgNotify)
: mNetSession(netSession),
mBufferProducer(bufferProducer),
mRTPPort(0),
@@ -283,7 +283,7 @@ namespace android
mNumPacketsReceived(0ll),
mRegression(1000),
mMaxDelayMs(-1ll),
- mStopNotify(stopNotify),
+ mMsgNotify(msgNotify),
mIsHDCP(false)
{
mDumpEnable = getPropertyInt("sys.wfddump", 0);
@@ -680,7 +680,7 @@ namespace android
sp<AMessage> notifyLost = new AMessage(kWhatPacketLost, this);
notifyLost->setInt32("ssrc", srcId);
- mRenderer = new TunnelRenderer(notifyLost, mBufferProducer, mStopNotify);
+ mRenderer = new TunnelRenderer(notifyLost, mBufferProducer, mMsgNotify);
looper()->registerHandler(mRenderer);
mRenderer->setIsHDCP(mIsHDCP);
diff --git a/libstagefright/wifi-display/sink/RTPSink.h b/libstagefright/wifi-display/sink/RTPSink.h
index a0f7af1..4501d78 100644
--- a/libstagefright/wifi-display/sink/RTPSink.h
+++ b/libstagefright/wifi-display/sink/RTPSink.h
@@ -39,7 +39,7 @@ namespace android
{
RTPSink(const sp<AmANetworkSession> &netSession,
const sp<IGraphicBufferProducer> &bufferProducer,
- const sp<AMessage> &stopNotify);
+ const sp<AMessage> &msgNotify);
// If TCP interleaving is used, no UDP sockets are created, instead
// incoming RTP/RTCP packets (arriving on the RTSP control connection)
@@ -84,7 +84,7 @@ namespace android
int64_t mNumPacketsReceived;
LinearRegression mRegression;
int64_t mMaxDelayMs;
- sp<AMessage> mStopNotify;
+ sp<AMessage> mMsgNotify;
sp<TunnelRenderer> mRenderer;
int32_t mDumpEnable;
diff --git a/libstagefright/wifi-display/sink/TunnelRenderer.cpp b/libstagefright/wifi-display/sink/TunnelRenderer.cpp
index fadb881..eec7b7c 100644
--- a/libstagefright/wifi-display/sink/TunnelRenderer.cpp
+++ b/libstagefright/wifi-display/sink/TunnelRenderer.cpp
@@ -207,7 +207,7 @@ namespace android
TunnelRenderer::TunnelRenderer(
const sp<AMessage> &notifyLost,
const sp<IGraphicBufferProducer> &bufferProducer,
- const sp<AMessage> &stopNotify)
+ const sp<AMessage> &msgNotify)
: mNotifyLost(notifyLost),
mBufferProducer(bufferProducer),
mTotalBytesQueued(0ll),
@@ -223,7 +223,7 @@ namespace android
mPackageRequest(0),
mRequestedRetry(false),
mRequestedRetransmission(false),
- mStopNotify(stopNotify),
+ mMsgNotify(msgNotify),
mIsHDCP(false)
{
mCurTime = ALooper::GetNowUs();
@@ -341,7 +341,8 @@ namespace android
if (ret == 0)
{
ALOGI("no packets available beyond 12 secs,stop WifiDisplaySink now");
- sp<AMessage> notify = mStopNotify->dup();
+ sp<AMessage> notify = mMsgNotify->dup();
+ notify->setInt32("msg", kWhatNoPacketMsg);
notify->post();
mFirstFailedAttemptUs = ALooper::GetNowUs();
}
@@ -405,7 +406,6 @@ namespace android
if (mFirstFailedAttemptUs < 0ll)
{
mFirstFailedAttemptUs = ALooper::GetNowUs();
-
ALOGI("failed to get the correct packet the first time.");
return NULL;
}
@@ -422,7 +422,10 @@ namespace android
sp<AMessage> notify = mNotifyLost->dup();
notify->setInt32("seqNo", (mLastDequeuedExtSeqNo + 1) & 0xffff);
notify->post();
-
+ //For miracast, we shuold send request IDR to request a I Frame asap
+ sp<AMessage> msgNotify = mMsgNotify->dup();
+ msgNotify->setInt32("msg", kWahtLostPacketMsg);
+ msgNotify->post();
mRequestedRetry = true;
mRequestedRetransmission = true;
mRetryTimes++;
@@ -437,7 +440,6 @@ namespace android
ALOGI("dropping packet. extSeqNo %d didn't arrive in time",
mLastDequeuedExtSeqNo + 1);
-
// Permanent failure, we never received the packet.
mPackageFailed++;
diff --git a/libstagefright/wifi-display/sink/TunnelRenderer.h b/libstagefright/wifi-display/sink/TunnelRenderer.h
index feb982a..2f3089d 100644
--- a/libstagefright/wifi-display/sink/TunnelRenderer.h
+++ b/libstagefright/wifi-display/sink/TunnelRenderer.h
@@ -29,7 +29,6 @@ using namespace std;
namespace android
{
-
struct ABuffer;
class SurfaceComposerClient;
class SurfaceControl;
@@ -45,7 +44,7 @@ namespace android
TunnelRenderer(
const sp<AMessage> &notifyLost,
const sp<IGraphicBufferProducer> &bufferProducer,
- const sp<AMessage> &stopNotify);
+ const sp<AMessage> &msgNotify);
sp<ABuffer> dequeueBuffer();
@@ -54,6 +53,11 @@ namespace android
kWhatQueueBuffer,
};
+ enum {
+ kWhatNoPacketMsg,
+ kWahtLostPacketMsg,
+ };
+
void setIsHDCP(bool isHDCP);
bool getIsHDCP() { return mIsHDCP; }
protected:
@@ -93,7 +97,7 @@ namespace android
int32_t mPackageRequest;
bool mRequestedRetry;
bool mRequestedRetransmission;
- sp<AMessage> mStopNotify;
+ sp<AMessage> mMsgNotify;
//sp<SystemControlClient > mSystemControlService;
bool mIsHDCP;
diff --git a/libstagefright/wifi-display/sink/WifiDisplaySink.cpp b/libstagefright/wifi-display/sink/WifiDisplaySink.cpp
index 031feb1..31e7a53 100644
--- a/libstagefright/wifi-display/sink/WifiDisplaySink.cpp
+++ b/libstagefright/wifi-display/sink/WifiDisplaySink.cpp
@@ -68,7 +68,8 @@ namespace android
mUsingHDCP(false),
mNeedHDCP(false),
mResolution(Normal),
- mHDCPRunning(false)
+ mHDCPRunning(false),
+ mIDRFrameRequestPending(false)
{
srand(time(0));
mHDCPPort = 9000 + rand() % 100;
@@ -248,7 +249,7 @@ namespace android
case kWhatStart:
{
ALOGI("Received msg kWhatStart.");
- mNotifyStop = new AMessage(kWhatNoPacket, this);
+ mMsgNotify = new AMessage(kWhatNoPacket, this);
if (msg->findString("setupURI", &mSetupURI))
{
AString path, user, pass;
@@ -480,11 +481,27 @@ namespace android
}
case kWhatNoPacket:
{
- sp<AMessage> msg = new AMessage(kWhatSinkNotify, mSinkHandler);
- ALOGI("post msg kWhatSinkNotify - RTP no packets");
- msg->setString("reason", "RTP_NO_PACKET");
- msg->post();
-
+ int32_t msgCode;
+ CHECK(msg->findInt32("msg", &msgCode));
+ switch (msgCode)
+ {
+ case kWhatNoPacketMsg: {
+ sp<AMessage> msg = new AMessage(kWhatSinkNotify, mSinkHandler);
+ ALOGI("post msg kWhatSinkNotify - RTP no packets");
+ msg->setString("reason", "RTP_NO_PACKET");
+ msg->post();
+ break;
+ }
+ case kWahtLostPacketMsg: {
+ if (!mIDRFrameRequestPending) {
+ ALOGI("requesting IDR frame");
+ sendIDRFrameRequest(mSessionID);
+ }
+ break;
+ }
+ default:
+ break;
+ }
break;
}
default:
@@ -1018,7 +1035,7 @@ namespace android
if (mRTPSink == NULL)
{
- mRTPSink = new RTPSink(mNetSession, mBufferProducer, mNotifyStop);
+ mRTPSink = new RTPSink(mNetSession, mBufferProducer, mMsgNotify);
looper()->registerHandler(mRTPSink);
err = mRTPSink->init(sUseTCPInterleaving);
@@ -1134,7 +1151,7 @@ namespace android
if (mRTPSink == NULL)
{
- mRTPSink = new RTPSink(mNetSession, mBufferProducer, mNotifyStop);
+ mRTPSink = new RTPSink(mNetSession, mBufferProducer, mMsgNotify);
looper()->registerHandler(mRTPSink);
err = mRTPSink->init(sUseTCPInterleaving);
@@ -1315,6 +1332,38 @@ namespace android
response->append(AStringPrintf("CSeq: %d\r\n", cseq));
}
}
+
+ status_t WifiDisplaySink::onReceiveIDRFrameRequestResponse(
+ int32_t sessionID, const sp<ParsedMessage> &msg) {
+ CHECK(mIDRFrameRequestPending);
+ mIDRFrameRequestPending = false;
+ ALOGI("sessionID=%d, has msg = %d", sessionID, msg != NULL);
+ return OK;
+ }
+
+ status_t WifiDisplaySink::sendIDRFrameRequest(int32_t sessionID) {
+ CHECK(!mIDRFrameRequestPending);
+ AString request = "SET_PARAMETER rtsp://localhost/wfd1.0 RTSP/1.0\r\n";
+ AppendCommonResponse(&request, mNextCSeq);
+ AString content = "wfd_idr_request\r\n";
+ request.append(AStringPrintf("Session: %s\r\n", mPlaybackSessionID.c_str()));
+ request.append(AStringPrintf("Content-Length: %d\r\n", content.size()));
+ request.append("\r\n");
+ request.append(content);
+ ALOGD("===== Send IDR Request =====");
+ status_t err = mNetSession->sendRequest(sessionID, request.c_str(), request.size());
+ if (err != OK) {
+ return err;
+ }
+ registerResponseHandler(
+ sessionID,
+ mNextCSeq,
+ &WifiDisplaySink::onReceiveIDRFrameRequestResponse);
+ ++mNextCSeq;
+ mIDRFrameRequestPending = true;
+ return OK;
+ }
+
#if 1
WifiDisplaySink::HDCPObserver::HDCPObserver(
const sp<AMessage> &notify)
diff --git a/libstagefright/wifi-display/sink/WifiDisplaySink.h b/libstagefright/wifi-display/sink/WifiDisplaySink.h
index ab25a0c..0294883 100644
--- a/libstagefright/wifi-display/sink/WifiDisplaySink.h
+++ b/libstagefright/wifi-display/sink/WifiDisplaySink.h
@@ -161,7 +161,7 @@ namespace android
AString mPlaybackSessionID;
int32_t mPlaybackSessionTimeoutSecs;
sp<AHandler> mSinkHandler;
- sp<AMessage> mNotifyStop;
+ sp<AMessage> mMsgNotify;
int32_t mRTSPPort;
int32_t mConnectionRetry;
#define MAX_CONN_RETRY 500
@@ -257,7 +257,7 @@ namespace android
AString *user, AString *pass);
int save_sessionid_to_file(char* filepath, int32_t sessionID);
-
+ bool mIDRFrameRequestPending;
status_t sendIDRFrameRequest(int32_t sessionID);
status_t onReceiveIDRFrameRequestResponse(
int32_t sessionID, const sp<ParsedMessage> &msg);