summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDhavalkumar Chaudhary <dhavalc@google.com>2023-03-10 07:01:16 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-03-10 07:01:16 +0000
commita569cd73a7094f30a1f7a48be1004371e21271e0 (patch)
tree26dcfc542b1ec656683246ab1d35642b85d24ab2
parentac0ecc07d7ebb0f24f6ee552e4be2216af35a6bd (diff)
parentbb5cf4f7cc800429ede8c675e05a0a3014c325e5 (diff)
downloadImsMedia-a569cd73a7094f30a1f7a48be1004371e21271e0.tar.gz
Merge "Added DTX and OctetAligned configuration for audio source and player" into udc-dev am: bb5cf4f7cc
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/ImsMedia/+/21733974 Change-Id: Id4744cd1bf4ec817798212a0b78c486f7079098d Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/android/ImsMediaAudioPlayer.cpp18
-rw-r--r--service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/android/ImsMediaAudioSource.cpp12
-rw-r--r--service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/android/include/ImsMediaAudioPlayer.h19
-rw-r--r--service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/android/include/ImsMediaAudioSource.h17
-rw-r--r--service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/nodes/IAudioPlayerNode.cpp13
-rw-r--r--service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/nodes/IAudioSourceNode.cpp13
-rw-r--r--service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/audio/nodes/IAudioPlayerNode.h2
-rw-r--r--service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/audio/nodes/IAudioSourceNode.h2
8 files changed, 88 insertions, 8 deletions
diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/android/ImsMediaAudioPlayer.cpp b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/android/ImsMediaAudioPlayer.cpp
index 2f71f13e..4a05166a 100644
--- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/android/ImsMediaAudioPlayer.cpp
+++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/android/ImsMediaAudioPlayer.cpp
@@ -42,8 +42,10 @@ ImsMediaAudioPlayer::ImsMediaAudioPlayer()
mCodec = nullptr;
mSamplingRate = DEFAULT_SAMPLING_RATE;
mEvsCodecHeaderMode = kRtpPyaloadHeaderModeEvsHeaderFull;
- mFirstFrame = false;
+ mIsFirstFrame = false;
mIsEvsInitialized = false;
+ mIsOctetAligned = false;
+ mIsDtxEnabled = false;
}
ImsMediaAudioPlayer::~ImsMediaAudioPlayer() {}
@@ -85,6 +87,16 @@ void ImsMediaAudioPlayer::SetCodecMode(uint32_t mode)
mCodecMode = mode;
}
+void ImsMediaAudioPlayer::SetDtxEnabled(bool isDtxEnabled)
+{
+ mIsDtxEnabled = isDtxEnabled;
+}
+
+void ImsMediaAudioPlayer::SetOctetAligned(bool isOctetAligned)
+{
+ mIsOctetAligned = isOctetAligned;
+}
+
bool ImsMediaAudioPlayer::Start()
{
char kMimeType[128] = {'\0'};
@@ -368,10 +380,10 @@ bool ImsMediaAudioPlayer::decodeEvs(uint8_t* buffer, uint32_t size)
mIsEvsInitialized = true;
}
- if (!mFirstFrame)
+ if (!mIsFirstFrame)
{
IMLOGD0("[decodeEvs] First frame has been decoded");
- mFirstFrame = true;
+ mIsFirstFrame = true;
}
AAudioStream_write(mAudioStream, output, (decodeSize / 2), 0);
diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/android/ImsMediaAudioSource.cpp b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/android/ImsMediaAudioSource.cpp
index 9117e0ad..d383cfd1 100644
--- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/android/ImsMediaAudioSource.cpp
+++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/android/ImsMediaAudioSource.cpp
@@ -50,6 +50,8 @@ ImsMediaAudioSource::ImsMediaAudioSource()
mEvsChAwOffset = 0;
mIsEvsInitialized = false;
mMediaDirection = 0;
+ mIsDtxEnabled = false;
+ mIsOctetAligned = false;
}
ImsMediaAudioSource::~ImsMediaAudioSource() {}
@@ -104,6 +106,16 @@ void ImsMediaAudioSource::SetMediaDirection(int32_t direction)
mMediaDirection = direction;
}
+void ImsMediaAudioSource::SetDtxEnabled(bool isDtxEnabled)
+{
+ mIsDtxEnabled = isDtxEnabled;
+}
+
+void ImsMediaAudioSource::SetOctetAligned(bool isOctetAligned)
+{
+ mIsOctetAligned = isOctetAligned;
+}
+
bool ImsMediaAudioSource::Start()
{
char kMimeType[128] = {'\0'};
diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/android/include/ImsMediaAudioPlayer.h b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/android/include/ImsMediaAudioPlayer.h
index 1b19e342..92c12d9d 100644
--- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/android/include/ImsMediaAudioPlayer.h
+++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/android/include/ImsMediaAudioPlayer.h
@@ -82,6 +82,21 @@ public:
void SetEvsPayloadHeaderMode(int32_t EvsPayloadHeaderMode);
/**
+ * @brief Set Whether discontinuous transmission is enabled or not
+ *
+ * @params isDtxEnabled, if set to true then enable discontinuous transmission
+ */
+ void SetDtxEnabled(bool isDtxEnabled);
+
+ /**
+ * @brief Setting octet-align for AMR/AMR-WB
+ *
+ * @params isOctetAligned, If it's set to true then all fields in the AMR/AMR-WB header
+ * shall be aligned to octet boundaries by adding padding bits.
+ */
+ void SetOctetAligned(bool isOctetAligned);
+
+ /**
* @brief Starts audio player to play the decoded audio frame and ndk audio decoder to decode
* the given data
*
@@ -127,8 +142,10 @@ private:
std::mutex mMutex;
int32_t mEvsBitRate;
kRtpPyaloadHeaderMode mEvsCodecHeaderMode;
- bool mFirstFrame;
+ bool mIsFirstFrame;
bool mIsEvsInitialized;
+ bool mIsDtxEnabled;
+ bool mIsOctetAligned;
};
#endif
diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/android/include/ImsMediaAudioSource.h b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/android/include/ImsMediaAudioSource.h
index 63ed1ad7..d838a8cc 100644
--- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/android/include/ImsMediaAudioSource.h
+++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/android/include/ImsMediaAudioSource.h
@@ -102,6 +102,21 @@ public:
void SetMediaDirection(int32_t direction);
/**
+ * @brief Set Whether discontinuous transmission is enabled or not
+ *
+ * @params isDtxEnabled, if set to true then enable discontinuous transmission
+ */
+ void SetDtxEnabled(bool isDtxEnabled);
+
+ /**
+ * @brief Setting octet-align for AMR/AMR-WB
+ *
+ * @params isOctetAligned, If it's set to true then all fields in the AMR/AMR-WB header
+ * shall be aligned to octet boundaries by adding padding bits.
+ */
+ void SetOctetAligned(bool isOctetAligned);
+
+ /**
* @brief Starts aaudio and ndk audio codec to get the audio frame and encode the audio frames
* with given configuration
*
@@ -149,6 +164,8 @@ private:
ImsMediaCondition mConditionExit;
bool mIsEvsInitialized;
int32_t mMediaDirection;
+ bool mIsDtxEnabled;
+ bool mIsOctetAligned;
};
#endif
diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/nodes/IAudioPlayerNode.cpp b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/nodes/IAudioPlayerNode.cpp
index c37fba98..9e57dc90 100644
--- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/nodes/IAudioPlayerNode.cpp
+++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/nodes/IAudioPlayerNode.cpp
@@ -29,6 +29,8 @@ IAudioPlayerNode::IAudioPlayerNode(BaseSessionCallback* callback) :
std::unique_ptr<ImsMediaAudioPlayer> track(new ImsMediaAudioPlayer());
mAudioPlayer = std::move(track);
mConfig = nullptr;
+ mIsOctetAligned = false;
+ mIsDtxEnabled = false;
}
IAudioPlayerNode::~IAudioPlayerNode()
@@ -59,6 +61,8 @@ ImsMediaResult IAudioPlayerNode::ProcessStart()
{
mAudioPlayer->SetCodec(mCodecType);
mAudioPlayer->SetSamplingRate(mSamplingRate * 1000);
+ mAudioPlayer->SetDtxEnabled(mIsDtxEnabled);
+ mAudioPlayer->SetOctetAligned(mIsOctetAligned);
if (mCodecType == kAudioCodecEvs)
{
@@ -130,6 +134,7 @@ void IAudioPlayerNode::SetConfig(void* config)
if (mCodecType == kAudioCodecAmr || mCodecType == kAudioCodecAmrWb)
{
mMode = mConfig->getAmrParams().getAmrMode();
+ mIsOctetAligned = mConfig->getAmrParams().getOctetAligned();
}
else if (mCodecType == kAudioCodecEvs)
{
@@ -141,6 +146,7 @@ void IAudioPlayerNode::SetConfig(void* config)
}
mSamplingRate = mConfig->getSamplingRateKHz();
+ mIsDtxEnabled = mConfig->getDtxEnabled();
SetJitterBufferSize(4, 4, 9);
SetJitterOptions(
80, 1, (double)25 / 10, false /** TODO: when enable DTX, set this true on condition*/
@@ -161,7 +167,9 @@ bool IAudioPlayerNode::IsSameConfig(void* config)
if (mCodecType == kAudioCodecAmr || mCodecType == kAudioCodecAmrWb)
{
return (mMode == pConfig->getAmrParams().getAmrMode() &&
- mSamplingRate == pConfig->getSamplingRateKHz());
+ mSamplingRate == pConfig->getSamplingRateKHz() &&
+ mIsDtxEnabled == pConfig->getDtxEnabled() &&
+ mIsOctetAligned == pConfig->getAmrParams().getOctetAligned());
}
else if (mCodecType == kAudioCodecEvs)
{
@@ -171,7 +179,8 @@ bool IAudioPlayerNode::IsSameConfig(void* config)
pConfig->getEvsParams().getEvsBandwidth()) &&
mEvsChannelAwOffset == pConfig->getEvsParams().getChannelAwareMode() &&
mSamplingRate == pConfig->getSamplingRateKHz() &&
- mEvsPayloadHeaderMode == pConfig->getEvsParams().getUseHeaderFullOnly());
+ mEvsPayloadHeaderMode == pConfig->getEvsParams().getUseHeaderFullOnly() &&
+ mIsDtxEnabled == pConfig->getDtxEnabled());
}
}
diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/nodes/IAudioSourceNode.cpp b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/nodes/IAudioSourceNode.cpp
index 8bedca46..3eff8305 100644
--- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/nodes/IAudioSourceNode.cpp
+++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/nodes/IAudioSourceNode.cpp
@@ -33,6 +33,8 @@ IAudioSourceNode::IAudioSourceNode(BaseSessionCallback* callback) :
mRunningCodecMode = 0;
mFirstFrame = false;
mMediaDirection = 0;
+ mIsOctetAligned = false;
+ mIsDtxEnabled = false;
}
IAudioSourceNode::~IAudioSourceNode() {}
@@ -54,6 +56,8 @@ ImsMediaResult IAudioSourceNode::ProcessStart()
mAudioSource->SetPtime(mPtime);
mAudioSource->SetSamplingRate(mSamplingRate * 1000);
mAudioSource->SetMediaDirection(mMediaDirection);
+ mAudioSource->SetDtxEnabled(mIsDtxEnabled);
+ mAudioSource->SetOctetAligned(mIsOctetAligned);
if (mCodecType == kAudioCodecEvs)
{
@@ -120,6 +124,7 @@ void IAudioSourceNode::SetConfig(void* config)
if (mCodecType == kAudioCodecAmr || mCodecType == kAudioCodecAmrWb)
{
mCodecMode = pConfig->getAmrParams().getAmrMode();
+ mIsOctetAligned = pConfig->getAmrParams().getOctetAligned();
}
else if (mCodecType == kAudioCodecEvs)
{
@@ -132,6 +137,7 @@ void IAudioSourceNode::SetConfig(void* config)
mMediaDirection = pConfig->getMediaDirection();
mSamplingRate = pConfig->getSamplingRateKHz();
mPtime = pConfig->getPtimeMillis();
+ mIsDtxEnabled = pConfig->getDtxEnabled();
}
bool IAudioSourceNode::IsSameConfig(void* config)
@@ -149,7 +155,9 @@ bool IAudioSourceNode::IsSameConfig(void* config)
{
return (mCodecMode == pConfig->getAmrParams().getAmrMode() &&
mSamplingRate == pConfig->getSamplingRateKHz() &&
- mMediaDirection == pConfig->getMediaDirection());
+ mMediaDirection == pConfig->getMediaDirection() &&
+ mIsDtxEnabled == pConfig->getDtxEnabled() &&
+ mIsOctetAligned == pConfig->getAmrParams().getOctetAligned());
}
else if (mCodecType == kAudioCodecEvs)
{
@@ -159,7 +167,8 @@ bool IAudioSourceNode::IsSameConfig(void* config)
pConfig->getEvsParams().getEvsBandwidth()) &&
mEvsChAwOffset == pConfig->getEvsParams().getChannelAwareMode() &&
mSamplingRate == pConfig->getSamplingRateKHz() &&
- mMediaDirection == pConfig->getMediaDirection());
+ mMediaDirection == pConfig->getMediaDirection() &&
+ mIsDtxEnabled == pConfig->getDtxEnabled());
}
}
diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/audio/nodes/IAudioPlayerNode.h b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/audio/nodes/IAudioPlayerNode.h
index cb41c0c6..a041f25f 100644
--- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/audio/nodes/IAudioPlayerNode.h
+++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/audio/nodes/IAudioPlayerNode.h
@@ -54,6 +54,8 @@ private:
kEvsBandwidth mEvsBandwidth;
int8_t mSamplingRate;
int32_t mEvsPayloadHeaderMode;
+ bool mIsDtxEnabled;
+ bool mIsOctetAligned;
};
#endif
diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/audio/nodes/IAudioSourceNode.h b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/audio/nodes/IAudioSourceNode.h
index 1f5d8d6e..741556b0 100644
--- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/audio/nodes/IAudioSourceNode.h
+++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/audio/nodes/IAudioSourceNode.h
@@ -68,6 +68,8 @@ public:
int8_t mSamplingRate;
int8_t mEvsChAwOffset;
int32_t mMediaDirection;
+ bool mIsDtxEnabled;
+ bool mIsOctetAligned;
};
#endif