|
|
Chromium Code Reviews|
Created:
5 years, 1 month ago by qiangchen Modified:
5 years, 1 month ago CC:
chromium-reviews, mlamouri+watch-content_chromium.org, posciak+watch_chromium.org, jam, mcasas+watch_chromium.org, feature-media-reviews_chromium.org, darin-cc_chromium.org, mkwst+moarreviews-renderer_chromium.org Base URL:
https://chromium.googlesource.com/chromium/src.git@master Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
DescriptionWebRTC render smoothness test shows on mac platform the timestamps on the video frames are quite irregular. The reason is that we read the system clock time, when the frame is available to chromium, but the system clock may not be high definition.
In this CL, we changed the behavior to reading timestamp from the capture driver.
BUG=549744
TEST=all unit test and browser test passing, apprtc working as before.
Committed: https://crrev.com/543582a37b414c18a7593560bbfe4eda978e41f0
Cr-Commit-Position: refs/heads/master@{#359620}
Patch Set 1 : #
Total comments: 6
Patch Set 2 : Fallback #
Total comments: 4
Patch Set 3 : Style #Patch Set 4 : Alignment #
Messages
Total messages: 41 (17 generated)
Patchset #1 (id:1) has been deleted
Description was changed from ========== Revert Unnecessary Change Merge branch 'Timestamp' into Timestamp2 Mac TS Let reference time propagate BUG= ========== to ========== Revert Unnecessary Change Merge branch 'Timestamp' into Timestamp2 Mac TS Let reference time propagate BUG= ==========
Description was changed from ========== Revert Unnecessary Change Merge branch 'Timestamp' into Timestamp2 Mac TS Let reference time propagate BUG= ========== to ========== WebRTC render smoothness test shows on windows platform the timestamps on the video frames are quite irregular. The reason is that we read the system clock time, when the frame is available to chromium, but the system clock may not be high definition. In this CL, we changed the behavior to reading timestamp from the capture driver. BUG=549744 TEST=all unit test and browser test passing, apprtc working as before. ==========
qiangchen@chromium.org changed reviewers: + mcasas@chromium.org
Patchset #1 (id:20001) has been deleted
Patchset #1 (id:40001) has been deleted
Description was changed from ========== WebRTC render smoothness test shows on windows platform the timestamps on the video frames are quite irregular. The reason is that we read the system clock time, when the frame is available to chromium, but the system clock may not be high definition. In this CL, we changed the behavior to reading timestamp from the capture driver. BUG=549744 TEST=all unit test and browser test passing, apprtc working as before. ========== to ========== WebRTC render smoothness test shows on mac platform the timestamps on the video frames are quite irregular. The reason is that we read the system clock time, when the frame is available to chromium, but the system clock may not be high definition. In this CL, we changed the behavior to reading timestamp from the capture driver. BUG=549744 TEST=all unit test and browser test passing, apprtc working as before. ==========
A similiar CL as we did not for Windows timestamp.
Almost there. https://codereview.chromium.org/1421583007/diff/60001/media/capture/video/mac... File media/capture/video/mac/video_capture_device_avfoundation_mac.mm (right): https://codereview.chromium.org/1421583007/diff/60001/media/capture/video/mac... media/capture/video/mac/video_capture_device_avfoundation_mac.mm:331: const int microseconds_per_second = 1000000; Instead of |microseconds_per_second|, you should use base::TimeBase::kMicrosecondsPerSecond| [1], here and in the QTKit file. [1] https://code.google.com/p/chromium/codesearch#chromium/src/base/time/time.h&s... https://codereview.chromium.org/1421583007/diff/60001/media/capture/video/mac... media/capture/video/mac/video_capture_device_avfoundation_mac.mm:334: const base::TimeTicks timestamp = At least DCHECK_NE(0, cm_timestamp.timescale); https://codereview.chromium.org/1421583007/diff/60001/media/capture/video/mac... File media/capture/video/mac/video_capture_device_qtkit_mac.mm (right): https://codereview.chromium.org/1421583007/diff/60001/media/capture/video/mac... media/capture/video/mac/video_capture_device_qtkit_mac.mm:327: QTTime qt_timestamp = [sampleBuffer presentationTime]; const
Patchset #2 (id:80001) has been deleted
Patchset #2 (id:100001) has been deleted
Did a fallback code path for invalid raw timestamps. https://codereview.chromium.org/1421583007/diff/60001/media/capture/video/mac... File media/capture/video/mac/video_capture_device_avfoundation_mac.mm (right): https://codereview.chromium.org/1421583007/diff/60001/media/capture/video/mac... media/capture/video/mac/video_capture_device_avfoundation_mac.mm:331: const int microseconds_per_second = 1000000; On 2015/10/31 03:24:25, mcasas wrote: > Instead of |microseconds_per_second|, you should use > base::TimeBase::kMicrosecondsPerSecond| [1], here and > in the QTKit file. > > [1] > https://code.google.com/p/chromium/codesearch#chromium/src/base/time/time.h&s... Done. https://codereview.chromium.org/1421583007/diff/60001/media/capture/video/mac... media/capture/video/mac/video_capture_device_avfoundation_mac.mm:334: const base::TimeTicks timestamp = On 2015/10/31 03:24:25, mcasas wrote: > At least DCHECK_NE(0, cm_timestamp.timescale); Did a fallback code path in case the timestamp is invalid. https://codereview.chromium.org/1421583007/diff/60001/media/capture/video/mac... File media/capture/video/mac/video_capture_device_qtkit_mac.mm (right): https://codereview.chromium.org/1421583007/diff/60001/media/capture/video/mac... media/capture/video/mac/video_capture_device_qtkit_mac.mm:327: QTTime qt_timestamp = [sampleBuffer presentationTime]; On 2015/10/31 03:24:25, mcasas wrote: > const Done.
https://codereview.chromium.org/1421583007/diff/120001/media/capture/video/ma... File media/capture/video/mac/video_capture_device_avfoundation_mac.mm (right): https://codereview.chromium.org/1421583007/diff/120001/media/capture/video/ma... media/capture/video/mac/video_capture_device_avfoundation_mac.mm:8: #import <CoreMedia/CoreMedia.h> Imports, same as includes, should follow alphabetical order. So, swap l.7 and 8. https://codereview.chromium.org/1421583007/diff/120001/media/capture/video/ma... media/capture/video/mac/video_capture_device_avfoundation_mac.mm:335: if ((cm_timestamp.flags & kCMTimeFlags_Valid) && cm_timestamp.timescale) { What about const base::TimeTicks timestamp = CMTIME_IS_INVALID(cm_timestamp) ? base::TimeTicks::Now() : base::TimeTicks() + base::TimeDelta::FromMicroseconds( cm_timestamp.value * base::TimeTicks::kMicrosecondsPerSecond / cm_timestamp.timescale); I would think that |cm_timestamp.timescale != 0| is included in the validity. Or even better: const base::TimeTicks timestamp = CMTIME_IS_VALID(cm_timestamp) ? base::TimeTicks() + base::TimeDelta::FromSecondsD(CMTimeGetSeconds(cm_timestamp)) : base::TimeTicks::Now(); Which is more readable IMHO, WDYT?
Done. https://codereview.chromium.org/1421583007/diff/120001/media/capture/video/ma... File media/capture/video/mac/video_capture_device_avfoundation_mac.mm (right): https://codereview.chromium.org/1421583007/diff/120001/media/capture/video/ma... media/capture/video/mac/video_capture_device_avfoundation_mac.mm:8: #import <CoreMedia/CoreMedia.h> On 2015/11/02 18:59:18, mcasas wrote: > Imports, same as includes, should follow alphabetical > order. So, swap l.7 and 8. Done. https://codereview.chromium.org/1421583007/diff/120001/media/capture/video/ma... media/capture/video/mac/video_capture_device_avfoundation_mac.mm:335: if ((cm_timestamp.flags & kCMTimeFlags_Valid) && cm_timestamp.timescale) { On 2015/11/02 18:59:18, mcasas wrote: > What about > > const base::TimeTicks timestamp = > CMTIME_IS_INVALID(cm_timestamp) > ? base::TimeTicks::Now() > : base::TimeTicks() + base::TimeDelta::FromMicroseconds( > cm_timestamp.value * > base::TimeTicks::kMicrosecondsPerSecond / > cm_timestamp.timescale); > > I would think that |cm_timestamp.timescale != 0| > is included in the validity. > > Or even better: > > const base::TimeTicks timestamp = > CMTIME_IS_VALID(cm_timestamp) > ? base::TimeTicks() + > base::TimeDelta::FromSecondsD(CMTimeGetSeconds(cm_timestamp)) > : base::TimeTicks::Now(); > > Which is more readable IMHO, WDYT? Done. But not using CMTimeGetSeconds, because CoreMediaGlue::CMTime is not the apple defined CMTime, but we redefined the same struct in coremedia_glue.h. Not sure why, but in order to use a CM*** function, we have to expose it from the library in coremedia_glue.h(and .cc) in a tedious way as we did for CMGetPresentationTime, which I do not think necessary for just time format conversion.
lgtm
The CQ bit was checked by qiangchen@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1421583007/140001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1421583007/140001
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: chromium_presubmit on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromium_presub...)
qiangchen@chromium.org changed reviewers: + dalecurtis@chromium.org
Hi, Dale
Can you take a quick look at this CL. We are solving the issue of capture
timestamp irregularity on Mac.
Hi, Dale:
Can you take a quick look at this CL, specially the two files under
media/base. Miguel has gone through the code review.
The clock timestamps at receiving the captured data contain noises that
would finally bring down the rendering smoothness. We instead try to extract
timestamp from the media sample, which is much better.
Qiang
dalecurtis@chromium.org changed reviewers: + miu@chromium.org
Hmm, well by doing this TimeTicks is no longer meaningful if we end up comparing it with other TimeTicks (say ::Now() which the VideoRendererAlgorithm will do based on compositor clock). What's the core problem with the tick clock in this case? Is it drifting relative to the frame timestamp? +miu who has experience in these matters.
On 2015/11/05 23:56:55, DaleCurtis wrote:
> Hmm, well by doing this TimeTicks is no longer meaningful if we end up
comparing
> it with other TimeTicks (say ::Now() which the VideoRendererAlgorithm will do
> based on compositor clock).
>
> What's the core problem with the tick clock in this case? Is it drifting
> relative to the frame timestamp?
>
> +miu who has experience in these matters.
Yep. The irregularity is not drift but the noise in frame length.
For example for 30FPS, we may observe frame length pattern like
{32,31,33,32....,47}. The timestamps taken from the sample buffer
are much better.
The defect of this simple solution is the alignment of the TimeTicks with Now(),
as mentioned by Dale. But functionally, it should be fine. As in
VideoCaptureImpl::OnBufferReceived, when VideoFrame is generated, only
elapsed timestamp (timestamp - first_timestamp) is used.
Or maybe, should we make another clean up CL to switch using TimeDelta
representing
timestamps all the way on the capture code path?
Ping miu@ for suggestions on how to convert the raw sample timestamps (essentially from capture API) to TimeTicks.
On 2015/11/09 18:02:34, qiangchenC wrote:
> Ping miu@ for suggestions on how to convert the raw sample timestamps
> (essentially from capture API) to TimeTicks.
TimeTicks *means* a snapshot of the common monotonic reference clock, which is a
different clock than what the capturing device is using. Thus, these timestamp
values must always be generated relative to at least one call to
TimeTicks::Now().
I recommend you do the following in your code:
/* ...in class declaration... */
// These values are used to map timestamps from the capture device's clock to
the local reference clock (TimeTicks).
base::TimeTicks first_frame_reference_time_;
CoreMediaGlue::CMTime first_frame_pts_;
/* ...in .cc code... */
// The capture timestamp from the clock of the capture device.
const CoreMediaGlue::CMTime pts =
CoreMediaGlue::CMSampleBufferGetPresentationTimeStamp(sampleBuffer);
// Translate the capture timestamp to be in terms of the local reference
clock.
base::TimeTicks reference_time;
if (first_frame_reference_time_.is_null()) {
first_frame_reference_time_ = reference_time = base::TimeTicks::Now();
first_frame_pts_ = pts;
} else {
const base::TimeDelta elapsed =
base::TimeDelta::FromSecondsD(CMTimeGetSeconds(CMTimeSubtract(pts,
first_frame_pts_)));
reference_time = first_frame_reference_time_ + elapsed;
}
The above will do what you want, but there is always the possibility the two
clocks will skew (i.e., run at a different rates) relative to each other. The
solution to that would be something like ClockDriftSmoother
(https://code.google.com/p/chromium/codesearch#chromium/src/media/cast/common/...).
However, that may be overkill for this use case. If there is no clock skew
adjustment in the video capture pipeline, it's likely this will occasionally
(once every several minutes/hours) cause either: 1) an excess frame to be
dropped; or 2) hold a frame for extra time. You may want to confirm the rates
of excess/dropped frames is acceptable by testing on actual hardware.
BTW--Your CL description is incorrect: TimeTicks has <1 usec resolution on the
Mac/iOS platforms, so it *is* "high definition." ;-)
Did a timestamp alignment with Now().
Did a timestamp alignment with Now().
lgtm
The CQ bit was checked by qiangchen@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from mcasas@chromium.org Link to the patchset: https://codereview.chromium.org/1421583007/#ps160001 (title: "Alignment")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1421583007/160001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1421583007/160001
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: chromium_presubmit on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromium_presub...)
Ping dale@ to take a look at it. Other reviewers are not owner of media/base files.
lgtm
The CQ bit was checked by qiangchen@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1421583007/160001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1421583007/160001
Message was sent while issue was closed.
Committed patchset #4 (id:160001)
Message was sent while issue was closed.
Patchset 4 (id:??) landed as https://crrev.com/543582a37b414c18a7593560bbfe4eda978e41f0 Cr-Commit-Position: refs/heads/master@{#359620} |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
