Merge changes I424ba760,Ic0826085
* changes:
MTP: Implement extra object properties for audio, video and image files
MediaStore: Add helper method to create Uri for querying genre for an audio file
diff --git a/media/libeffects/visualizer/EffectVisualizer.cpp b/media/libeffects/visualizer/EffectVisualizer.cpp
index 03a6bbb..5505f14 100644
--- a/media/libeffects/visualizer/EffectVisualizer.cpp
+++ b/media/libeffects/visualizer/EffectVisualizer.cpp
@@ -65,8 +65,8 @@
{
pContext->mCaptureIdx = 0;
pContext->mCurrentBuf = 0;
- memset(pContext->mCaptureBuf[0], 0, VISUALIZER_CAPTURE_SIZE_MAX);
- memset(pContext->mCaptureBuf[1], 0, VISUALIZER_CAPTURE_SIZE_MAX);
+ memset(pContext->mCaptureBuf[0], 0x80, VISUALIZER_CAPTURE_SIZE_MAX);
+ memset(pContext->mCaptureBuf[1], 0x80, VISUALIZER_CAPTURE_SIZE_MAX);
}
//----------------------------------------------------------------------------
diff --git a/media/libmedia/AudioEffect.cpp b/media/libmedia/AudioEffect.cpp
index 0f3e245..88b8c86 100644
--- a/media/libmedia/AudioEffect.cpp
+++ b/media/libmedia/AudioEffect.cpp
@@ -228,24 +228,32 @@
void *replyData)
{
if (mStatus != NO_ERROR && mStatus != ALREADY_EXISTS) {
+ LOGV("command() bad status %d", mStatus);
return INVALID_OPERATION;
}
+ if ((cmdCode == EFFECT_CMD_ENABLE || cmdCode == EFFECT_CMD_DISABLE) &&
+ (replySize == NULL || *replySize != sizeof(status_t) || replyData == NULL)) {
+ return BAD_VALUE;
+ }
+
status_t status = mIEffect->command(cmdCode, cmdSize, cmdData, replySize, replyData);
if (status != NO_ERROR) {
return status;
}
- status = *(status_t *)replyData;
- if (status != NO_ERROR) {
- return status;
+
+ if (cmdCode == EFFECT_CMD_ENABLE || cmdCode == EFFECT_CMD_DISABLE) {
+ status = *(status_t *)replyData;
+ if (status != NO_ERROR) {
+ return status;
+ }
+ if (cmdCode == EFFECT_CMD_ENABLE) {
+ android_atomic_or(1, &mEnabled);
+ } else {
+ android_atomic_and(~1, &mEnabled);
+ }
}
- if (cmdCode == EFFECT_CMD_ENABLE) {
- android_atomic_or(1, &mEnabled);
- }
- if (cmdCode == EFFECT_CMD_DISABLE) {
- android_atomic_and(~1, &mEnabled);
- }
return status;
}
diff --git a/media/libmedia/Visualizer.cpp b/media/libmedia/Visualizer.cpp
index 39552b6..68f2e9b 100644
--- a/media/libmedia/Visualizer.cpp
+++ b/media/libmedia/Visualizer.cpp
@@ -169,11 +169,13 @@
status_t status = NO_ERROR;
if (mEnabled) {
uint32_t replySize = mCaptureSize;
- status_t status = command(VISU_CMD_CAPTURE, 0, NULL, &replySize, waveform);
+ status = command(VISU_CMD_CAPTURE, 0, NULL, &replySize, waveform);
+ LOGV("getWaveForm() command returned %d", status);
if (replySize == 0) {
status = NOT_ENOUGH_DATA;
}
} else {
+ LOGV("getWaveForm() disabled");
memset(waveform, 0x80, mCaptureSize);
}
return status;
@@ -191,7 +193,7 @@
status_t status = NO_ERROR;
if (mEnabled) {
uint8_t buf[mCaptureSize];
- status_t status = getWaveForm(buf);
+ status = getWaveForm(buf);
if (status == NO_ERROR) {
status = doFft(fft, buf);
}
diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp
index ba1e218..e6c2f7e 100644
--- a/media/libstagefright/MPEG4Writer.cpp
+++ b/media/libstagefright/MPEG4Writer.cpp
@@ -1541,20 +1541,52 @@
int32_t isSync = false;
meta_data->findInt32(kKeyIsSyncFrame, &isSync);
+ /*
+ * The original timestamp found in the data buffer will be modified as below:
+ *
+ * There is a playback offset into this track if the track's start time
+ * is not the same as the movie start time, which will be recorded in edst
+ * box of the output file. The playback offset is to make sure that the
+ * starting time of the audio/video tracks are synchronized. Although the
+ * track's media timestamp may be subject to various modifications
+ * as outlined below, the track's playback offset time remains unchanged
+ * once the first data buffer of the track is received.
+ *
+ * The media time stamp will be calculated by subtracting the playback offset
+ * (and potential pause durations) from the original timestamp in the buffer.
+ *
+ * If this track is a video track for a real-time recording application with
+ * both audio and video tracks, its media timestamp will subject to further
+ * modification based on the media clock of the audio track. This modification
+ * is needed for the purpose of maintaining good audio/video synchronization.
+ *
+ * If the recording session is paused and resumed multiple times, the track
+ * media timestamp will be modified as if the recording session had never been
+ * paused at all during playback of the recorded output file. In other words,
+ * the output file will have no memory of pause/resume durations.
+ *
+ */
CHECK(meta_data->findInt64(kKeyTime, ×tampUs));
+ LOGV("%s timestampUs: %lld", mIsAudio? "Audio": "Video", timestampUs);
////////////////////////////////////////////////////////////////////////////////
if (mSampleSizes.empty()) {
mStartTimestampUs = timestampUs;
mOwner->setStartTimestampUs(mStartTimestampUs);
+ previousPausedDurationUs = mStartTimestampUs;
}
if (mResumed) {
- previousPausedDurationUs += (timestampUs - mTrackDurationUs - lastDurationUs);
+ int64_t durExcludingEarlierPausesUs = timestampUs - previousPausedDurationUs;
+ CHECK(durExcludingEarlierPausesUs >= 0);
+ int64_t pausedDurationUs = durExcludingEarlierPausesUs - mTrackDurationUs;
+ CHECK(pausedDurationUs >= lastDurationUs);
+ previousPausedDurationUs += pausedDurationUs - lastDurationUs;
mResumed = false;
}
timestampUs -= previousPausedDurationUs;
+ CHECK(timestampUs >= 0);
if (mIsRealTimeRecording && !mIsAudio) {
// The minor adjustment on the timestamp is heuristic/experimental
// We are adjusting the timestamp to reduce the fluctuation of the duration
@@ -1590,8 +1622,8 @@
}
}
- LOGV("time stamp: %lld and previous paused duration %lld",
- timestampUs, previousPausedDurationUs);
+ LOGV("%s media time stamp: %lld and previous paused duration %lld",
+ mIsAudio? "Audio": "Video", timestampUs, previousPausedDurationUs);
if (timestampUs > mTrackDurationUs) {
mTrackDurationUs = timestampUs;
}
@@ -1873,6 +1905,7 @@
// First elst entry: specify the starting time offset
int64_t offsetUs = mStartTimestampUs - moovStartTimeUs;
+ LOGV("OffsetUs: %lld", offsetUs);
int32_t seg = (offsetUs * mvhdTimeScale + 5E5) / 1E6;
mOwner->writeInt32(seg); // in mvhd timecale
mOwner->writeInt32(-1); // starting time offset
diff --git a/media/libstagefright/NuHTTPDataSource.cpp b/media/libstagefright/NuHTTPDataSource.cpp
index 332bab3..2743b2f 100644
--- a/media/libstagefright/NuHTTPDataSource.cpp
+++ b/media/libstagefright/NuHTTPDataSource.cpp
@@ -96,6 +96,11 @@
return connect(host, port, path, headers, offset);
}
+static bool IsRedirectStatusCode(int httpStatus) {
+ return httpStatus == 301 || httpStatus == 302
+ || httpStatus == 303 || httpStatus == 307;
+}
+
status_t NuHTTPDataSource::connect(
const char *host, unsigned port, const char *path,
const String8 &headers,
@@ -161,7 +166,7 @@
return err;
}
- if (httpStatus == 302) {
+ if (IsRedirectStatusCode(httpStatus)) {
string value;
CHECK(mHTTP.find_header_value("Location", &value));
diff --git a/telephony/java/com/android/internal/telephony/sip/SipPhone.java b/telephony/java/com/android/internal/telephony/sip/SipPhone.java
index 08194d4..ed581df 100755
--- a/telephony/java/com/android/internal/telephony/sip/SipPhone.java
+++ b/telephony/java/com/android/internal/telephony/sip/SipPhone.java
@@ -636,6 +636,18 @@
}
@Override
+ public void onCallEstablished(SipAudioCall call) {
+ call.startAudio();
+ onChanged(call);
+ }
+
+ @Override
+ public void onCallHeld(SipAudioCall call) {
+ call.startAudio();
+ onChanged(call);
+ }
+
+ @Override
public void onChanged(SipAudioCall call) {
synchronized (SipPhone.class) {
Call.State newState = getCallStateFrom(call);
@@ -655,7 +667,6 @@
}
foregroundCall.switchWith(ringingCall);
}
- if (newState == Call.State.ACTIVE) call.startAudio();
setState(newState);
}
mOwner.onConnectionStateChanged(SipConnection.this);
diff --git a/voip/jni/rtp/AudioGroup.cpp b/voip/jni/rtp/AudioGroup.cpp
index 7cf06137..81d4dfc 100644
--- a/voip/jni/rtp/AudioGroup.cpp
+++ b/voip/jni/rtp/AudioGroup.cpp
@@ -86,6 +86,8 @@
void decode(int tick);
private:
+ bool isNatAddress(struct sockaddr_storage *addr);
+
enum {
NORMAL = 0,
SEND_ONLY = 1,
@@ -316,6 +318,16 @@
sizeof(mRemote));
}
+bool AudioStream::isNatAddress(struct sockaddr_storage *addr) {
+ if (addr->ss_family != AF_INET) return false;
+ struct sockaddr_in *s4 = (struct sockaddr_in *)addr;
+ unsigned char *d = (unsigned char *) &s4->sin_addr;
+ if ((d[0] == 10)
+ || ((d[0] == 172) && (d[1] & 0x10))
+ || ((d[0] == 192) && (d[1] == 168))) return true;
+ return false;
+}
+
void AudioStream::decode(int tick)
{
char c;
@@ -363,8 +375,21 @@
MSG_TRUNC | MSG_DONTWAIT) >> 1;
} else {
__attribute__((aligned(4))) uint8_t buffer[2048];
- length = recv(mSocket, buffer, sizeof(buffer),
- MSG_TRUNC | MSG_DONTWAIT);
+ struct sockaddr_storage src_addr;
+ socklen_t addrlen;
+ length = recvfrom(mSocket, buffer, sizeof(buffer),
+ MSG_TRUNC|MSG_DONTWAIT, (sockaddr*)&src_addr, &addrlen);
+
+ // The following if clause is for fixing the target address if
+ // proxy server did not replace the NAT address with its media
+ // port in SDP. Although it is proxy server's responsibility for
+ // replacing the connection address with correct one, we will change
+ // the target address as we detect the difference for now until we
+ // know the best way to get rid of this issue.
+ if ((memcmp((void*)&src_addr, (void*)&mRemote, addrlen) != 0) &&
+ isNatAddress(&mRemote)) {
+ memcpy((void*)&mRemote, (void*)&src_addr, addrlen);
+ }
// Do we need to check SSRC, sequence, and timestamp? They are not
// reliable but at least they can be used to identify duplicates?