Bug 1032065 - RTSP video playback quality is poor if payload type is MP4V-ES. r=sworkman, r=bechen
authorEthan Tseng <ettseng@mozilla.com>
Fri, 11 Jul 2014 17:29:47 +0800
changeset 215760 0d4079709d5bbf8903ffbe4e4ce88606da56f4dc
parent 215598 af9414da9bbc165fd5608a458faa1f7d67990e65
child 215761 8c62d9b5f1af799215b2a70bece0234609f53ea5
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssworkman, bechen
bugs1032065
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1032065 - RTSP video playback quality is poor if payload type is MP4V-ES. r=sworkman, r=bechen
netwerk/protocol/rtsp/rtsp/AMPEG4ElementaryAssembler.cpp
--- a/netwerk/protocol/rtsp/rtsp/AMPEG4ElementaryAssembler.cpp
+++ b/netwerk/protocol/rtsp/rtsp/AMPEG4ElementaryAssembler.cpp
@@ -354,22 +354,62 @@ ARTPAssembler::AssemblyStatus AMPEG4Elem
     return OK;
 }
 
 void AMPEG4ElementaryAssembler::submitAccessUnit() {
     CHECK(!mPackets.empty());
 
     LOGV("Access unit complete (%d nal units)", mPackets.size());
 
-    for (List<sp<ABuffer> >::iterator it = mPackets.begin();
-         it != mPackets.end(); ++it) {
-        sp<ABuffer> accessUnit = new ABuffer((*it)->size());
-        sp<ABuffer> nal = *it;
-        memcpy(accessUnit->data(), nal->data(), nal->size());
-        CopyTimes(accessUnit, nal);
+    if (mIsGeneric) {
+        /*
+         * Bug 877116.
+         * In order to remedy a latency problem caused by hardware decoder for
+         * mpeg4-generic audios, we artificially divide AUs into more smaller
+         * AUs before feeding them to decoder.
+         *
+         * TODO: However, we are not sure this solution is appropriate to video
+         * or not. Need more investigation on this. Refer to RFC 3640.
+         */
+        for (List<sp<ABuffer> >::iterator it = mPackets.begin();
+             it != mPackets.end(); ++it) {
+            sp<ABuffer> accessUnit = new ABuffer((*it)->size());
+            sp<ABuffer> nal = *it;
+            memcpy(accessUnit->data(), nal->data(), nal->size());
+            CopyTimes(accessUnit, nal);
+
+            if (mAccessUnitDamaged) {
+                accessUnit->meta()->setInt32("damaged", true);
+            }
+
+            sp<AMessage> msg = mNotifyMsg->dup();
+            msg->setObject("access-unit", accessUnit);
+            msg->post();
+        }
+    } else {
+        /*
+         * For MP4V-ES (MPEG-4 Visual Elementary Streams), NAL units with the
+         * same RTP timestamp are assembled into an AU, which results in one
+         * decoded picture (RFC 6416).
+         */
+        size_t totalSize = 0;
+
+        for (List<sp<ABuffer> >::iterator it = mPackets.begin();
+             it != mPackets.end(); ++it) {
+            totalSize += (*it)->size();
+        }
+        sp<ABuffer> accessUnit = new ABuffer(totalSize);
+        size_t offset = 0;
+        for (List<sp<ABuffer> >::iterator it = mPackets.begin();
+             it != mPackets.end(); ++it) {
+            sp<ABuffer> nal = *it;
+            memcpy(accessUnit->data() + offset, nal->data(), nal->size());
+            offset += nal->size();
+        }
+        CopyTimes(accessUnit, *mPackets.begin());
 
         if (mAccessUnitDamaged) {
             accessUnit->meta()->setInt32("damaged", true);
         }
 
         sp<AMessage> msg = mNotifyMsg->dup();
         msg->setObject("access-unit", accessUnit);
         msg->post();