diff options
author | Bodam Nam <bodamnam@google.com> | 2023-04-11 07:52:37 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-04-11 07:52:37 +0000 |
commit | 49d5768c3581c1c68d6886b5bc7db8090692cb20 (patch) | |
tree | 48e6c31c93d86e94b8990075bfaf1f34ea3684fe /service/src | |
parent | c12432d6b84adbb44f070baf395879e68ebab26e (diff) | |
parent | 92337d569130be377615fb8421adbced82f49811 (diff) | |
download | ImsMedia-49d5768c3581c1c68d6886b5bc7db8090692cb20.tar.gz |
Merge "Implementation of video downgrade opreration API" into udc-dev am: 92337d5691
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/ImsMedia/+/21466709
Change-Id: I45a361753f2bb0b68114ad92da36632cfea91d4c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'service/src')
14 files changed, 97 insertions, 21 deletions
diff --git a/service/src/com/android/telephony/imsmedia/Utils.java b/service/src/com/android/telephony/imsmedia/Utils.java index 651413b5..5459e6c8 100644 --- a/service/src/com/android/telephony/imsmedia/Utils.java +++ b/service/src/com/android/telephony/imsmedia/Utils.java @@ -392,6 +392,7 @@ public final class Utils { .setRtpPacketLossRate(in.rtpPacketLossRate) .setRtpJitterMillis(in.rtpJitterMillis) .setNotifyCurrentStatus(in.notifyCurrentStatus) + .setVideoBitrateBps(0) .build(); } diff --git a/service/src/com/android/telephony/imsmedia/VideoListener.java b/service/src/com/android/telephony/imsmedia/VideoListener.java index ce70114b..32122974 100644 --- a/service/src/com/android/telephony/imsmedia/VideoListener.java +++ b/service/src/com/android/telephony/imsmedia/VideoListener.java @@ -92,7 +92,7 @@ public class VideoListener implements JNIImsMediaListener { //TODO: add implementation break; case VideoSession.EVENT_MEDIA_INACTIVITY_IND: - case VideoSession.EVENT_PACKET_LOSS_IND: + case VideoSession.EVENT_NOTIFY_BITRATE_IND: Utils.sendMessage(mHandler, event, parcel.readInt(), Utils.UNUSED); break; case VideoSession.EVENT_VIDEO_DATA_USAGE_IND: diff --git a/service/src/com/android/telephony/imsmedia/VideoSession.java b/service/src/com/android/telephony/imsmedia/VideoSession.java index 5ade826e..02d47ad9 100644 --- a/service/src/com/android/telephony/imsmedia/VideoSession.java +++ b/service/src/com/android/telephony/imsmedia/VideoSession.java @@ -59,7 +59,7 @@ public final class VideoSession extends IImsVideoSession.Stub implements IMediaS public static final int EVENT_PEER_DIMENSION_CHANGED = 205; public static final int EVENT_RTP_HEADER_EXTENSION_IND = 206; public static final int EVENT_MEDIA_INACTIVITY_IND = 207; - public static final int EVENT_PACKET_LOSS_IND = 208; + public static final int EVENT_NOTIFY_BITRATE_IND = 208; public static final int EVENT_VIDEO_DATA_USAGE_IND = 209; public static final int EVENT_SESSION_CLOSED = 210; @@ -233,8 +233,8 @@ public final class VideoSession extends IImsVideoSession.Stub implements IMediaS case EVENT_MEDIA_INACTIVITY_IND: handleNotifyMediaInactivityInd(msg.arg1); break; - case EVENT_PACKET_LOSS_IND: - handleNotifyPacketLossInd(msg.arg1); + case EVENT_NOTIFY_BITRATE_IND: + handleNotifyBitrateInd(msg.arg1); break; case EVENT_VIDEO_DATA_USAGE_IND: handleNotifyVideoDataUsage((long) msg.obj); @@ -344,9 +344,9 @@ public final class VideoSession extends IImsVideoSession.Stub implements IMediaS } } - private void handleNotifyPacketLossInd(int percentage) { + private void handleNotifyBitrateInd(int percentage) { try { - mCallback.notifyPacketLoss(percentage); + mCallback.notifyBitrate(percentage); } catch (RemoteException e) { Log.e(TAG, "Failed to notify packet loss: " + e); } diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/config/include/MediaQualityThreshold.h b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/config/include/MediaQualityThreshold.h index ecb33980..d7b7ced3 100644 --- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/config/include/MediaQualityThreshold.h +++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/config/include/MediaQualityThreshold.h @@ -58,6 +58,8 @@ public: std::vector<int32_t> getRtpJitterMillis() const; void setNotifyCurrentStatus(bool status); bool getNotifyCurrentStatus() const; + void setVideoBitrateBps(int32_t bitrate); + int32_t getVideoBitrateBps() const; private: /** The timer in milliseconds for monitoring RTP inactivity */ @@ -85,6 +87,13 @@ private: * of the current status. */ bool mNotifyCurrentStatus; + + /** + * The receiving bitrate threshold in bps for video call. If it is not zero, bitrate + * notification event is triggered when the receiving frame bitrate is less than the + * threshold. + */ + int mVideoBitrateBps; }; } // namespace imsmedia diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/config/src/MediaQualityThreshold.cpp b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/config/src/MediaQualityThreshold.cpp index f0ca1473..c6ecefdd 100644 --- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/config/src/MediaQualityThreshold.cpp +++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/config/src/MediaQualityThreshold.cpp @@ -34,6 +34,7 @@ MediaQualityThreshold::MediaQualityThreshold() mRtpPacketLossRate.clear(); mRtpJitterMillis.clear(); mNotifyCurrentStatus = false; + mVideoBitrateBps = 0; } MediaQualityThreshold::MediaQualityThreshold(const MediaQualityThreshold& threshold) @@ -45,6 +46,7 @@ MediaQualityThreshold::MediaQualityThreshold(const MediaQualityThreshold& thresh mRtpPacketLossRate = threshold.mRtpPacketLossRate; mRtpJitterMillis = threshold.mRtpJitterMillis; mNotifyCurrentStatus = threshold.mNotifyCurrentStatus; + mVideoBitrateBps = threshold.mVideoBitrateBps; } MediaQualityThreshold::~MediaQualityThreshold() {} @@ -60,6 +62,7 @@ MediaQualityThreshold& MediaQualityThreshold::operator=(const MediaQualityThresh mRtpPacketLossRate = threshold.mRtpPacketLossRate; mRtpJitterMillis = threshold.mRtpJitterMillis; mNotifyCurrentStatus = threshold.mNotifyCurrentStatus; + mVideoBitrateBps = threshold.mVideoBitrateBps; } return *this; } @@ -72,7 +75,8 @@ bool MediaQualityThreshold::operator==(const MediaQualityThreshold& threshold) c mRtpPacketLossDurationMillis == threshold.mRtpPacketLossDurationMillis && mRtpPacketLossRate == threshold.mRtpPacketLossRate && mRtpJitterMillis == threshold.mRtpJitterMillis && - mNotifyCurrentStatus == threshold.mNotifyCurrentStatus); + mNotifyCurrentStatus == threshold.mNotifyCurrentStatus && + mVideoBitrateBps == threshold.mVideoBitrateBps); } bool MediaQualityThreshold::operator!=(const MediaQualityThreshold& threshold) const @@ -83,7 +87,8 @@ bool MediaQualityThreshold::operator!=(const MediaQualityThreshold& threshold) c mRtpPacketLossDurationMillis != threshold.mRtpPacketLossDurationMillis || mRtpPacketLossRate != threshold.mRtpPacketLossRate || mRtpJitterMillis != threshold.mRtpJitterMillis || - mNotifyCurrentStatus != threshold.mNotifyCurrentStatus); + mNotifyCurrentStatus != threshold.mNotifyCurrentStatus || + mVideoBitrateBps != threshold.mVideoBitrateBps); } status_t MediaQualityThreshold::writeToParcel(Parcel* out) const @@ -113,6 +118,7 @@ status_t MediaQualityThreshold::writeToParcel(Parcel* out) const } out->writeInt32(mNotifyCurrentStatus ? 1 : 0); + out->writeInt32(mVideoBitrateBps); return NO_ERROR; } @@ -149,7 +155,7 @@ status_t MediaQualityThreshold::readFromParcel(const Parcel* in) int32_t value; in->readInt32(&value); value == 1 ? mNotifyCurrentStatus = true : mNotifyCurrentStatus = false; - + in->readInt32(&mVideoBitrateBps); return NO_ERROR; } @@ -223,6 +229,16 @@ bool MediaQualityThreshold::getNotifyCurrentStatus() const return mNotifyCurrentStatus; } +void MediaQualityThreshold::setVideoBitrateBps(int32_t bitrate) +{ + mVideoBitrateBps = bitrate; +} + +int32_t MediaQualityThreshold::getVideoBitrateBps() const +{ + return mVideoBitrateBps; +} + } // namespace imsmedia } // namespace telephony diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/ImsMediaDefine.h b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/ImsMediaDefine.h index 891513dd..75d70238 100644 --- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/ImsMediaDefine.h +++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/ImsMediaDefine.h @@ -52,6 +52,7 @@ enum kImsMediaEventType kImsMediaEventResolutionChanged, kImsMediaEventNotifyVideoDataUsage, kImsMediaEventNotifyRttReceived, + kImsMediaEventNotifyVideoLowestBitrate, }; // Internal Request Event @@ -331,7 +332,7 @@ enum ImsMediaVideoMsgResponse kVideoPeerDimensionChanged, kVideoRtpHeaderExtensionInd, kVideoMediaInactivityInd, - kVideoPacketLossInd, + kVideoBitrateInd, kVideoDataUsageInd, kVideoSessionClosed, }; diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/video/VideoStreamGraphRtpTx.h b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/video/VideoStreamGraphRtpTx.h index 1255d194..0fd1104a 100644 --- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/video/VideoStreamGraphRtpTx.h +++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/video/VideoStreamGraphRtpTx.h @@ -29,6 +29,7 @@ public: virtual ImsMediaResult create(RtpConfig* config); virtual ImsMediaResult update(RtpConfig* config); virtual ImsMediaResult start(); + virtual bool setMediaQualityThreshold(MediaQualityThreshold* threshold); void setSurface(ANativeWindow* surface); virtual bool OnEvent(int32_t type, uint64_t param1, uint64_t param2); diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/video/android/ImsMediaVideoSource.h b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/video/android/ImsMediaVideoSource.h index 83a6d7ac..b1adce53 100644 --- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/video/android/ImsMediaVideoSource.h +++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/video/android/ImsMediaVideoSource.h @@ -137,7 +137,7 @@ public: * * @param bitrate The bitrate in bps units */ - void changeBitrate(const uint32_t bitrate); + bool changeBitrate(const uint32_t bitrate); /** * @brief Request a new IDR frame to the codec output streaming diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/video/nodes/IVideoSourceNode.h b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/video/nodes/IVideoSourceNode.h index bcc43d5b..17acd172 100644 --- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/video/nodes/IVideoSourceNode.h +++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/video/nodes/IVideoSourceNode.h @@ -46,6 +46,14 @@ public: * @param window surface buffer to update */ void UpdateSurface(ANativeWindow* window); + + /** + * @brief Set the bitrate threshold to notify the indication when the encoding video bitrate is + * less than the threshold values + * + * @param bitrate The video encoding bitrate in bps unit + */ + void SetBitrateThreshold(int32_t bitrate); // callback from ImsMediaVideoSource virtual void OnUplinkEvent(uint8_t* pBitstream, uint32_t nSize, int64_t pstUsec, uint32_t flag); virtual void OnEvent(int32_t type, int32_t param1, int32_t param2); @@ -68,6 +76,8 @@ protected: android::String8 mImagePath; uint32_t mDeviceOrientation; ANativeWindow* mWindow; + int32_t mMinBitrateThreshold; + bool mBitrateNotified; }; #endif
\ No newline at end of file diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/video/VideoManager.cpp b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/video/VideoManager.cpp index 9d98be37..a52db04a 100644 --- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/video/VideoManager.cpp +++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/video/VideoManager.cpp @@ -407,12 +407,7 @@ void VideoManager::ResponseHandler::processEvent( // TODO : add implementation break; case kVideoMediaInactivityInd: - parcel.writeInt32(event); - parcel.writeInt32(static_cast<int>(paramA)); // type - parcel.writeInt32(static_cast<int>(paramB)); // duration - VideoManager::getInstance()->sendResponse(sessionId, parcel); - break; - case kVideoPacketLossInd: + case kVideoBitrateInd: parcel.writeInt32(event); parcel.writeInt32(static_cast<int>(paramA)); VideoManager::getInstance()->sendResponse(sessionId, parcel); diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/video/VideoSession.cpp b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/video/VideoSession.cpp index 074e37cf..ba43d0a0 100644 --- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/video/VideoSession.cpp +++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/video/VideoSession.cpp @@ -106,6 +106,7 @@ ImsMediaResult VideoSession::startGraph(RtpConfig* config) if (mGraphRtpTx != nullptr) { + mGraphRtpTx->setMediaQualityThreshold(&mThreshold); ret = mGraphRtpTx->update(config); if (ret != RESULT_SUCCESS) @@ -135,6 +136,7 @@ ImsMediaResult VideoSession::startGraph(RtpConfig* config) if (pConfig->getMediaDirection() == RtpConfig::MEDIA_DIRECTION_SEND_ONLY || pConfig->getMediaDirection() == RtpConfig::MEDIA_DIRECTION_SEND_RECEIVE) { + mGraphRtpTx->setMediaQualityThreshold(&mThreshold); ret = mGraphRtpTx->start(); } } @@ -265,6 +267,10 @@ void VideoSession::onEvent(int32_t type, uint64_t param1, uint64_t param2) ImsMediaEventHandler::SendEvent( "VIDEO_RESPONSE_EVENT", kVideoDataUsageInd, mSessionId, param1, param2); break; + case kImsMediaEventNotifyVideoLowestBitrate: + ImsMediaEventHandler::SendEvent( + "VIDEO_RESPONSE_EVENT", kVideoBitrateInd, mSessionId, param1, param2); + break; case kRequestVideoCvoUpdate: case kRequestVideoBitrateChange: case kRequestVideoIdrFrame: diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/video/VideoStreamGraphRtpTx.cpp b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/video/VideoStreamGraphRtpTx.cpp index 71a6f050..bc7c7dd0 100644 --- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/video/VideoStreamGraphRtpTx.cpp +++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/video/VideoStreamGraphRtpTx.cpp @@ -234,6 +234,23 @@ ImsMediaResult VideoStreamGraphRtpTx::start() return RESULT_SUCCESS; } +bool VideoStreamGraphRtpTx::setMediaQualityThreshold(MediaQualityThreshold* threshold) +{ + if (threshold != nullptr) + { + BaseNode* node = findNode(kNodeIdVideoSource); + + if (node != nullptr) + { + IVideoSourceNode* source = reinterpret_cast<IVideoSourceNode*>(node); + source->SetBitrateThreshold(threshold->getVideoBitrateBps()); + return true; + } + } + + return false; +} + void VideoStreamGraphRtpTx::setSurface(ANativeWindow* surface) { IMLOGI1("[setSurface] state[%d]", mGraphState); diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/video/android/ImsMediaVideoSource.cpp b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/video/android/ImsMediaVideoSource.cpp index 591b6d05..38b71771 100644 --- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/video/android/ImsMediaVideoSource.cpp +++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/video/android/ImsMediaVideoSource.cpp @@ -448,14 +448,14 @@ void ImsMediaVideoSource::onCameraFrame(AImage* pImage) processOutputBuffer(); } -void ImsMediaVideoSource::changeBitrate(const uint32_t bitrate) +bool ImsMediaVideoSource::changeBitrate(const uint32_t bitrate) { IMLOGD1("[changeBitrate] bitrate[%d]", bitrate); std::lock_guard<std::mutex> guard(mMutex); if (mStopped) { - return; + return false; } AMediaFormat* params = AMediaFormat_new(); @@ -465,7 +465,10 @@ void ImsMediaVideoSource::changeBitrate(const uint32_t bitrate) if (status != AMEDIA_OK) { IMLOGE1("[changeBitrate] error[%d]", status); + return false; } + + return true; } void ImsMediaVideoSource::requestIdrFrame() diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/video/nodes/IVideoSourceNode.cpp b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/video/nodes/IVideoSourceNode.cpp index a54dc377..c95f6240 100644 --- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/video/nodes/IVideoSourceNode.cpp +++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/video/nodes/IVideoSourceNode.cpp @@ -45,6 +45,8 @@ IVideoSourceNode::IVideoSourceNode(BaseSessionCallback* callback) : mImagePath = ""; mDeviceOrientation = 0; mWindow = nullptr; + mMinBitrateThreshold = 0; + mBitrateNotified = false; } IVideoSourceNode::~IVideoSourceNode() {} @@ -83,12 +85,13 @@ ImsMediaResult IVideoSourceNode::Start() mVideoSource->SetSurface(mWindow); - if (mVideoSource->Start() == false) + if (!mVideoSource->Start()) { return RESULT_NOT_READY; } mVideoSource->SetDeviceOrientation(mDeviceOrientation); + mBitrateNotified = false; } mNodeState = kNodeStateRunning; @@ -275,6 +278,12 @@ void IVideoSourceNode::OnUplinkEvent( } } +void IVideoSourceNode::SetBitrateThreshold(int32_t bitrate) +{ + IMLOGD1("[SetBitrateThreshold] bitrate[%d]", bitrate); + mMinBitrateThreshold = bitrate; +} + void IVideoSourceNode::OnEvent(int32_t type, int32_t param1, int32_t param2) { IMLOGD3("[OnEvent] type[%d], param1[%d], param2[%d]", type, param1, param2); @@ -296,7 +305,15 @@ void IVideoSourceNode::OnEvent(int32_t type, int32_t param1, int32_t param2) case kRequestVideoBitrateChange: if (mVideoSource != nullptr) { - mVideoSource->changeBitrate(param1); + if (mVideoSource->changeBitrate(param1)) + { + if (mMinBitrateThreshold != 0 && param1 <= mMinBitrateThreshold && + mCallback != nullptr && !mBitrateNotified) + { + mCallback->SendEvent(kImsMediaEventNotifyVideoLowestBitrate, param1); + mBitrateNotified = true; + } + } } break; case kRequestVideoIdrFrame: |