OSDN Git Service

Better video bandwidth utilization by not lying about the frame rate.
authorAndreas Huber <andih@google.com>
Wed, 12 Sep 2012 23:48:23 +0000 (16:48 -0700)
committerAndreas Huber <andih@google.com>
Thu, 13 Sep 2012 16:33:00 +0000 (09:33 -0700)
log network bandwidth used (for data traffic).

Change-Id: I043018624b3f02d94fa9c0cb9d15a6b2f2bd2eab

media/libstagefright/wifi-display/source/Converter.cpp
media/libstagefright/wifi-display/source/PlaybackSession.cpp
media/libstagefright/wifi-display/source/PlaybackSession.h

index 0e10b8d..c4845e3 100644 (file)
@@ -116,7 +116,7 @@ status_t Converter::initEncoder() {
         mOutputFormat->setInt32("bitrate", audioBitrate);
     } else {
         mOutputFormat->setInt32("bitrate", videoBitrate);
-        mOutputFormat->setInt32("frame-rate", 60);
+        mOutputFormat->setInt32("frame-rate", 30);
         mOutputFormat->setInt32("i-frame-interval", 3);  // Iframes every 3 secs
     }
 
index 41beba4..c38a300 100644 (file)
@@ -193,7 +193,8 @@ WifiDisplaySource::PlaybackSession::PlaybackSession(
       mNumSRsSent(0),
       mSendSRPending(false),
       mFirstPacketTimeUs(-1ll),
-      mHistoryLength(0)
+      mHistoryLength(0),
+      mTotalBytesSent(0ll)
 #if LOG_TRANSPORT_STREAM
       ,mLogFile(NULL)
 #endif
@@ -1023,6 +1024,14 @@ ssize_t WifiDisplaySource::PlaybackSession::appendTSData(
         } else {
             mNetSession->sendRequest(
                     mRTPSessionID, rtp, mTSQueue->size());
+
+            mTotalBytesSent += mTSQueue->size();
+            int64_t delayUs = ALooper::GetNowUs() - mFirstPacketTimeUs;
+
+            if (delayUs > 0ll) {
+                ALOGV("approx. net bandwidth used: %.2f Mbit/sec",
+                        mTotalBytesSent * 8.0 / delayUs);
+            }
         }
 
         mTSQueue->setInt32Data(mRTPSeqNo - 1);
index cd0308e..88f6ea9 100644 (file)
@@ -127,6 +127,8 @@ private:
     List<sp<ABuffer> > mHistory;
     size_t mHistoryLength;
 
+    uint64_t mTotalBytesSent;
+
 #if LOG_TRANSPORT_STREAM
     FILE *mLogFile;
 #endif