Bug 1291946 - Append the latest video frames from updateTracks. r?jesup, pehrsons. draft
authorctai <ctai@mozilla.com>
Wed, 10 Aug 2016 10:31:14 +0800
changeset 400633 c2ec19b1e169b783a296c94aebb2821cde3baf8c
parent 398604 6cf0089510fad8deb866136f5b92bbced9498447
child 400634 949a4f171f198fc8cf93c1a47f45034db1143fe4
child 401039 44f76ca77189ae1c2003c6cac839f040986fd7af
push id26220
push userbmo:ctai@mozilla.com
push dateMon, 15 Aug 2016 08:52:10 +0000
reviewersjesup, pehrsons
bugs1291946
milestone51.0a1
Bug 1291946 - Append the latest video frames from updateTracks. r?jesup, pehrsons. In some cases, we need to resend missed VideoSegment to new added MediaStreamVideoSink. Append the latest video frames from updateTracks. MozReview-Commit-ID: 76RFs5fgKpY
dom/media/MediaStreamGraph.cpp
dom/media/VideoSegment.h
--- a/dom/media/MediaStreamGraph.cpp
+++ b/dom/media/MediaStreamGraph.cpp
@@ -2787,17 +2787,22 @@ SourceMediaStream::AddDirectTrackListene
     // The track might be removed from mUpdateTrack but still exist in
     // mTracks.
     auto streamTrack = FindTrack(aTrackID);
     bool foundTrack = !!streamTrack;
     if (foundTrack) {
       MediaStreamVideoSink* videoSink = listener->AsMediaStreamVideoSink();
       // Re-send missed VideoSegment to new added MediaStreamVideoSink.
       if (streamTrack->GetType() == MediaSegment::VIDEO && videoSink) {
-        videoSink->SetCurrentFrames(*(static_cast<VideoSegment*>(streamTrack->GetSegment())));
+        VideoSegment videoSegment;
+        videoSegment.AppendSlice(*streamTrack->GetSegment(), mTracks.GetForgottenDuration(), streamTrack->GetSegment()->GetDuration());
+        if (found) {
+          videoSegment.AppendSlice(*data->mData, 0, data->mData->GetDuration());
+        }
+        videoSink->SetCurrentFrames(videoSegment);
       }
     }
 
     if (found && (isAudio || isVideo)) {
       for (auto entry : mDirectTrackListeners) {
         if (entry.mListener == listener &&
             (entry.mTrackID == TRACK_ANY || entry.mTrackID == aTrackID)) {
           listener->NotifyDirectListenerInstalled(
--- a/dom/media/VideoSegment.h
+++ b/dom/media/VideoSegment.h
@@ -87,19 +87,23 @@ struct VideoChunk {
   {
     // Future:
     // - mFrame
     return 0;
   }
 
   PrincipalHandle GetPrincipalHandle() const { return mFrame.GetPrincipalHandle(); }
 
+  TimeStamp GetTimeStamp() const {
+    return mTimeStamp;
+  }
+
   StreamTime mDuration;
   VideoFrame mFrame;
-  mozilla::TimeStamp mTimeStamp;
+  TimeStamp mTimeStamp;
 };
 
 class VideoSegment : public MediaSegmentBase<VideoSegment, VideoChunk> {
 public:
   typedef mozilla::layers::Image Image;
   typedef mozilla::gfx::IntSize IntSize;
 
   VideoSegment();