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
--- 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();