Bug 1300871 - Rollback to use original duration in video case. r?jesup
MozReview-Commit-ID: 2gK8vvBKtkC
--- a/dom/media/encoder/TrackEncoder.cpp
+++ b/dom/media/encoder/TrackEncoder.cpp
@@ -263,68 +263,52 @@ VideoTrackEncoder::NotifyQueuedTrackChan
Init(video);
AppendVideoSegment(video);
// The stream has stopped and reached the end of track.
if (aTrackEvents == TrackEventCommand::TRACK_EVENT_ENDED) {
LOG("[VideoTrackEncoder]: Receive TRACK_EVENT_ENDED .");
NotifyEndOfStream();
- mFirstFrame = true;
}
}
nsresult
VideoTrackEncoder::AppendVideoSegment(const VideoSegment& aSegment)
{
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
// Append all video segments from MediaStreamGraph, including null an
// non-null frames.
VideoSegment::ChunkIterator iter(const_cast<VideoSegment&>(aSegment));
while (!iter.IsEnded()) {
VideoChunk chunk = *iter;
- mTotalFrameDuration += chunk.GetDuration();
mLastFrameDuration += chunk.GetDuration();
// Send only the unique video frames for encoding.
// Or if we got the same video chunks more than 1 seconds,
// force to send into encoder.
if ((mLastFrame != chunk.mFrame) ||
(mLastFrameDuration >= mTrackRate)) {
RefPtr<layers::Image> image = chunk.mFrame.GetImage();
- // Fixme: see bug 1290777. We should remove the useage of duration here and
- // in |GetEncodedTrack|.
- StreamTime duration;
- if (mFirstFrame)
- {
- duration = chunk.GetDuration();
- mFirstFrame = false;
- } else {
- MOZ_ASSERT(chunk.mTimeStamp >= mLastFrameTimeStamp);
- TimeDuration timeDuration = chunk.mTimeStamp - mLastFrameTimeStamp;
- duration = SecondsToMediaTime(timeDuration.ToSeconds());
- }
-
// Because we may get chunks with a null image (due to input blocking),
// accumulate duration and give it to the next frame that arrives.
// Canonically incorrect - the duration should go to the previous frame
// - but that would require delaying until the next frame arrives.
// Best would be to do like OMXEncoder and pass an effective timestamp
// in with each frame.
if (image) {
mRawSegment.AppendFrame(image.forget(),
- duration,
+ mLastFrameDuration,
chunk.mFrame.GetIntrinsicSize(),
PRINCIPAL_HANDLE_NONE,
chunk.mFrame.GetForceBlack());
mLastFrameDuration = 0;
}
- mLastFrameTimeStamp = chunk.mTimeStamp;
}
mLastFrame.TakeFrom(&chunk.mFrame);
iter.Next();
}
if (mRawSegment.GetDuration() > 0) {
mReentrantMonitor.NotifyAll();
}
--- a/dom/media/encoder/TrackEncoder.h
+++ b/dom/media/encoder/TrackEncoder.h
@@ -253,18 +253,16 @@ public:
, mFrameWidth(0)
, mFrameHeight(0)
, mDisplayWidth(0)
, mDisplayHeight(0)
, mTrackRate(aTrackRate)
, mTotalFrameDuration(0)
, mLastFrameDuration(0)
, mVideoBitrate(0)
- , mLastFrameTimeStamp(TimeStamp::Now())
- , mFirstFrame(true)
{}
/**
* Notified by the same callback of MediaEncoder when it has received a track
* change from MediaStreamGraph. Called on the MediaStreamGraph thread.
*/
void NotifyQueuedTrackChanges(MediaStreamGraph* aGraph, TrackID aID,
StreamTime aTrackOffset,
@@ -354,17 +352,13 @@ protected:
StreamTime mLastFrameDuration;
/**
* A segment queue of audio track data, protected by mReentrantMonitor.
*/
VideoSegment mRawSegment;
uint32_t mVideoBitrate;
-
-private:
- TimeStamp mLastFrameTimeStamp;
- bool mFirstFrame;
};
} // namespace mozilla
#endif