if (buffer != NULL) {
CHECK(buffer->meta()->findInt64("timeUs", &timeUs));
- ALOGV("in: %s timeUs = %lld us", mIsVideo ? "video" : "audio", timeUs);
-
memcpy(mEncoderInputBuffers.itemAt(bufferIndex)->data(),
buffer->data(),
buffer->size());
notify->setInt32("what", kWhatEOS);
notify->post();
} else {
- ALOGV("out: %s timeUs = %lld us", mIsVideo ? "video" : "audio", timeUs);
-
sp<ABuffer> buffer = new ABuffer(size);
buffer->meta()->setInt64("timeUs", timeUs);
status_t start();
void stopAsync();
- bool isStopped() const { return !mStarted; }
-
void queueAccessUnit(const sp<ABuffer> &accessUnit);
sp<ABuffer> dequeueAccessUnit();
sp<AMessage> notify = mNotify->dup();
notify->setInt32("what", kWhatStopped);
notify->post();
+
+ ALOGI("kWhatStopped %s posted", mIsAudio ? "audio" : "video");
break;
}
mNumRTPOctetsSent(0),
mNumSRsSent(0),
mSendSRPending(false),
- mFirstPacketTimeUs(-1ll),
- mHistoryLength(0),
- mTotalBytesSent(0ll)
+ mHistoryLength(0)
+#if TRACK_BANDWIDTH
+ ,mFirstPacketTimeUs(-1ll),
+ ,mTotalBytesSent(0ll)
+#endif
#if LOG_TRANSPORT_STREAM
,mLogFile(NULL)
#endif
CHECK(msg->findSize("trackIndex", &trackIndex));
if (what == Track::kWhatStopped) {
- bool allTracksAreStopped = true;
- for (size_t i = 0; i < mTracks.size(); ++i) {
- const sp<Track> &track = mTracks.valueAt(i);
- if (!track->isStopped()) {
- allTracksAreStopped = false;
- break;
- }
- }
+ ALOGI("Track %d stopped", trackIndex);
- if (!allTracksAreStopped) {
+ sp<Track> track = mTracks.valueFor(trackIndex);
+ looper()->unregisterHandler(track->id());
+ mTracks.removeItem(trackIndex);
+ track.clear();
+
+ if (!mTracks.isEmpty()) {
+ ALOGI("not all tracks are stopped yet");
break;
}
- mTracks.clear();
-
mPacketizer.clear();
#if ENABLE_RETRANSMISSION
// flush
int64_t nowUs = ALooper::GetNowUs();
+
+#if TRACK_BANDWIDTH
if (mFirstPacketTimeUs < 0ll) {
mFirstPacketTimeUs = nowUs;
}
+#endif
// 90kHz time scale
- uint32_t rtpTime = ((nowUs - mFirstPacketTimeUs) * 9ll) / 100ll;
+ uint32_t rtpTime = (nowUs * 9ll) / 100ll;
uint8_t *rtp = mTSQueue->data();
rtp[0] = 0x80;
} else {
sendPacket(mRTPSessionID, rtp, mTSQueue->size());
+#if TRACK_BANDWIDTH
mTotalBytesSent += mTSQueue->size();
int64_t delayUs = ALooper::GetNowUs() - mFirstPacketTimeUs;
ALOGV("approx. net bandwidth used: %.2f Mbit/sec",
mTotalBytesSent * 8.0 / delayUs);
}
+#endif
}
mTSQueue->setInt32Data(mRTPSeqNo - 1);