Loading voip/jni/rtp/AudioGroup.cpp +16 −12 Original line number Diff line number Diff line Loading @@ -89,7 +89,6 @@ public: void encode(int tick, AudioStream *chain); void decode(int tick); private: enum { NORMAL = 0, SEND_ONLY = 1, Loading @@ -97,6 +96,7 @@ private: LAST_MODE = 2, }; private: int mMode; int mSocket; sockaddr_storage mRemote; Loading Loading @@ -202,8 +202,8 @@ bool AudioStream::set(int mode, int socket, sockaddr_storage *remote, } } LOGD("stream[%d] is configured as %s %dkHz %dms", mSocket, (codec ? codec->name : "RAW"), mSampleRate, mInterval); LOGD("stream[%d] is configured as %s %dkHz %dms mode %d", mSocket, (codec ? codec->name : "RAW"), mSampleRate, mInterval, mMode); return true; } Loading Loading @@ -253,7 +253,7 @@ void AudioStream::encode(int tick, AudioStream *chain) mTick += skipped * mInterval; mSequence += skipped; mTimestamp += skipped * mSampleCount; LOGD("stream[%d] skips %d packets", mSocket, skipped); LOGV("stream[%d] skips %d packets", mSocket, skipped); } tick = mTick; Loading Loading @@ -302,7 +302,7 @@ void AudioStream::encode(int tick, AudioStream *chain) if (!mixed) { if ((mTick ^ mLogThrottle) >> 10) { mLogThrottle = mTick; LOGD("stream[%d] no data", mSocket); LOGV("stream[%d] no data", mSocket); } return; } Loading Loading @@ -330,7 +330,7 @@ void AudioStream::encode(int tick, AudioStream *chain) buffer[2] = mSsrc; int length = mCodec->encode(&buffer[3], samples); if (length <= 0) { LOGD("stream[%d] encoder error", mSocket); LOGV("stream[%d] encoder error", mSocket); return; } sendto(mSocket, buffer, length + 12, MSG_DONTWAIT, (sockaddr *)&mRemote, Loading Loading @@ -369,14 +369,14 @@ void AudioStream::decode(int tick) mLatencyTimer = tick; mLatencyScore = score; } else if (tick - mLatencyTimer >= MEASURE_PERIOD) { LOGD("stream[%d] reduces latency of %dms", mSocket, mLatencyScore); LOGV("stream[%d] reduces latency of %dms", mSocket, mLatencyScore); mBufferTail -= mLatencyScore; mLatencyTimer = tick; } if (mBufferTail - mBufferHead > BUFFER_SIZE - mInterval) { // Buffer overflow. Drop the packet. LOGD("stream[%d] buffer overflow", mSocket); LOGV("stream[%d] buffer overflow", mSocket); recv(mSocket, &c, 1, MSG_DONTWAIT); return; } Loading @@ -400,7 +400,7 @@ void AudioStream::decode(int tick) // reliable but at least they can be used to identify duplicates? if (length < 12 || length > (int)sizeof(buffer) || (ntohl(*(uint32_t *)buffer) & 0xC07F0000) != mCodecMagic) { LOGD("stream[%d] malformed packet", mSocket); LOGV("stream[%d] malformed packet", mSocket); return; } int offset = 12 + ((buffer[0] & 0x0F) << 2); Loading @@ -420,13 +420,13 @@ void AudioStream::decode(int tick) } } if (length <= 0) { LOGD("stream[%d] decoder error", mSocket); LOGV("stream[%d] decoder error", mSocket); return; } if (tick - mBufferTail > 0) { // Buffer underrun. Reset the jitter buffer. LOGD("stream[%d] buffer underrun", mSocket); LOGV("stream[%d] buffer underrun", mSocket); if (mBufferTail - mBufferHead <= 0) { mBufferHead = tick + mInterval; mBufferTail = mBufferHead; Loading Loading @@ -462,7 +462,6 @@ public: bool add(AudioStream *stream); bool remove(int socket); private: enum { ON_HOLD = 0, MUTED = 1, Loading @@ -471,6 +470,7 @@ private: LAST_MODE = 3, }; private: AudioStream *mChain; int mEventQueue; volatile int mDtmfEvent; Loading Loading @@ -946,6 +946,10 @@ void remove(JNIEnv *env, jobject thiz, jint socket) void setMode(JNIEnv *env, jobject thiz, jint mode) { if (mode < 0 || mode > AudioGroup::LAST_MODE) { jniThrowException(env, "java/lang/IllegalArgumentException", NULL); return; } AudioGroup *group = (AudioGroup *)env->GetIntField(thiz, gNative); if (group && !group->setMode(mode)) { jniThrowException(env, "java/lang/IllegalArgumentException", NULL); Loading voip/jni/rtp/G711Codec.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ namespace { int8_t gExponents[128] = { const int8_t gExponents[128] = { 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, Loading voip/jni/rtp/RtpStream.cpp +3 −6 Original line number Diff line number Diff line Loading @@ -88,13 +88,11 @@ jint create(JNIEnv *env, jobject thiz, jstring jAddress) jint dup(JNIEnv *env, jobject thiz) { int socket1 = env->GetIntField(thiz, gNative); int socket2 = ::dup(socket1); if (socket2 == -1) { int socket = ::dup(env->GetIntField(thiz, gNative)); if (socket == -1) { jniThrowException(env, "java/lang/IllegalStateException", strerror(errno)); } LOGD("dup %d to %d", socket1, socket2); return socket2; return socket; } void close(JNIEnv *env, jobject thiz) Loading @@ -102,7 +100,6 @@ void close(JNIEnv *env, jobject thiz) int socket = env->GetIntField(thiz, gNative); ::close(socket); env->SetIntField(thiz, gNative, -1); LOGD("close %d", socket); } JNINativeMethod gMethods[] = { Loading Loading
voip/jni/rtp/AudioGroup.cpp +16 −12 Original line number Diff line number Diff line Loading @@ -89,7 +89,6 @@ public: void encode(int tick, AudioStream *chain); void decode(int tick); private: enum { NORMAL = 0, SEND_ONLY = 1, Loading @@ -97,6 +96,7 @@ private: LAST_MODE = 2, }; private: int mMode; int mSocket; sockaddr_storage mRemote; Loading Loading @@ -202,8 +202,8 @@ bool AudioStream::set(int mode, int socket, sockaddr_storage *remote, } } LOGD("stream[%d] is configured as %s %dkHz %dms", mSocket, (codec ? codec->name : "RAW"), mSampleRate, mInterval); LOGD("stream[%d] is configured as %s %dkHz %dms mode %d", mSocket, (codec ? codec->name : "RAW"), mSampleRate, mInterval, mMode); return true; } Loading Loading @@ -253,7 +253,7 @@ void AudioStream::encode(int tick, AudioStream *chain) mTick += skipped * mInterval; mSequence += skipped; mTimestamp += skipped * mSampleCount; LOGD("stream[%d] skips %d packets", mSocket, skipped); LOGV("stream[%d] skips %d packets", mSocket, skipped); } tick = mTick; Loading Loading @@ -302,7 +302,7 @@ void AudioStream::encode(int tick, AudioStream *chain) if (!mixed) { if ((mTick ^ mLogThrottle) >> 10) { mLogThrottle = mTick; LOGD("stream[%d] no data", mSocket); LOGV("stream[%d] no data", mSocket); } return; } Loading Loading @@ -330,7 +330,7 @@ void AudioStream::encode(int tick, AudioStream *chain) buffer[2] = mSsrc; int length = mCodec->encode(&buffer[3], samples); if (length <= 0) { LOGD("stream[%d] encoder error", mSocket); LOGV("stream[%d] encoder error", mSocket); return; } sendto(mSocket, buffer, length + 12, MSG_DONTWAIT, (sockaddr *)&mRemote, Loading Loading @@ -369,14 +369,14 @@ void AudioStream::decode(int tick) mLatencyTimer = tick; mLatencyScore = score; } else if (tick - mLatencyTimer >= MEASURE_PERIOD) { LOGD("stream[%d] reduces latency of %dms", mSocket, mLatencyScore); LOGV("stream[%d] reduces latency of %dms", mSocket, mLatencyScore); mBufferTail -= mLatencyScore; mLatencyTimer = tick; } if (mBufferTail - mBufferHead > BUFFER_SIZE - mInterval) { // Buffer overflow. Drop the packet. LOGD("stream[%d] buffer overflow", mSocket); LOGV("stream[%d] buffer overflow", mSocket); recv(mSocket, &c, 1, MSG_DONTWAIT); return; } Loading @@ -400,7 +400,7 @@ void AudioStream::decode(int tick) // reliable but at least they can be used to identify duplicates? if (length < 12 || length > (int)sizeof(buffer) || (ntohl(*(uint32_t *)buffer) & 0xC07F0000) != mCodecMagic) { LOGD("stream[%d] malformed packet", mSocket); LOGV("stream[%d] malformed packet", mSocket); return; } int offset = 12 + ((buffer[0] & 0x0F) << 2); Loading @@ -420,13 +420,13 @@ void AudioStream::decode(int tick) } } if (length <= 0) { LOGD("stream[%d] decoder error", mSocket); LOGV("stream[%d] decoder error", mSocket); return; } if (tick - mBufferTail > 0) { // Buffer underrun. Reset the jitter buffer. LOGD("stream[%d] buffer underrun", mSocket); LOGV("stream[%d] buffer underrun", mSocket); if (mBufferTail - mBufferHead <= 0) { mBufferHead = tick + mInterval; mBufferTail = mBufferHead; Loading Loading @@ -462,7 +462,6 @@ public: bool add(AudioStream *stream); bool remove(int socket); private: enum { ON_HOLD = 0, MUTED = 1, Loading @@ -471,6 +470,7 @@ private: LAST_MODE = 3, }; private: AudioStream *mChain; int mEventQueue; volatile int mDtmfEvent; Loading Loading @@ -946,6 +946,10 @@ void remove(JNIEnv *env, jobject thiz, jint socket) void setMode(JNIEnv *env, jobject thiz, jint mode) { if (mode < 0 || mode > AudioGroup::LAST_MODE) { jniThrowException(env, "java/lang/IllegalArgumentException", NULL); return; } AudioGroup *group = (AudioGroup *)env->GetIntField(thiz, gNative); if (group && !group->setMode(mode)) { jniThrowException(env, "java/lang/IllegalArgumentException", NULL); Loading
voip/jni/rtp/G711Codec.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ namespace { int8_t gExponents[128] = { const int8_t gExponents[128] = { 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, Loading
voip/jni/rtp/RtpStream.cpp +3 −6 Original line number Diff line number Diff line Loading @@ -88,13 +88,11 @@ jint create(JNIEnv *env, jobject thiz, jstring jAddress) jint dup(JNIEnv *env, jobject thiz) { int socket1 = env->GetIntField(thiz, gNative); int socket2 = ::dup(socket1); if (socket2 == -1) { int socket = ::dup(env->GetIntField(thiz, gNative)); if (socket == -1) { jniThrowException(env, "java/lang/IllegalStateException", strerror(errno)); } LOGD("dup %d to %d", socket1, socket2); return socket2; return socket; } void close(JNIEnv *env, jobject thiz) Loading @@ -102,7 +100,6 @@ void close(JNIEnv *env, jobject thiz) int socket = env->GetIntField(thiz, gNative); ::close(socket); env->SetIntField(thiz, gNative, -1); LOGD("close %d", socket); } JNINativeMethod gMethods[] = { Loading