Commit b18d81f6 authored by perkj's avatar perkj Committed by Commit bot

Change VideoTrackAdapter to not drop frames if the source frame rate is known.

Also change remote video and pepper plugin MediaStreamVideoSource implementations to not set a guessed frame rate.

BUG= 394315

Review URL: https://codereview.chromium.org/517973002

Cr-Commit-Position: refs/heads/master@{#292800}
parent 3b749672
...@@ -43,6 +43,7 @@ const char* kSupportedConstraints[] = { ...@@ -43,6 +43,7 @@ const char* kSupportedConstraints[] = {
const int MediaStreamVideoSource::kDefaultWidth = 640; const int MediaStreamVideoSource::kDefaultWidth = 640;
const int MediaStreamVideoSource::kDefaultHeight = 480; const int MediaStreamVideoSource::kDefaultHeight = 480;
const int MediaStreamVideoSource::kDefaultFrameRate = 30; const int MediaStreamVideoSource::kDefaultFrameRate = 30;
const int MediaStreamVideoSource::kUnknownFrameRate = 0;
namespace { namespace {
......
...@@ -81,6 +81,7 @@ class CONTENT_EXPORT MediaStreamVideoSource ...@@ -81,6 +81,7 @@ class CONTENT_EXPORT MediaStreamVideoSource
static const int kDefaultWidth; static const int kDefaultWidth;
static const int kDefaultHeight; static const int kDefaultHeight;
static const int kDefaultFrameRate; static const int kDefaultFrameRate;
static const int kUnknownFrameRate;
protected: protected:
virtual void DoStopSource() OVERRIDE; virtual void DoStopSource() OVERRIDE;
......
...@@ -89,7 +89,8 @@ class VideoTrackAdapter::VideoFrameResolutionAdapter ...@@ -89,7 +89,8 @@ class VideoTrackAdapter::VideoFrameResolutionAdapter
// Returns |true| if the input frame rate is higher that the requested max // Returns |true| if the input frame rate is higher that the requested max
// frame rate and |frame| should be dropped. // frame rate and |frame| should be dropped.
bool MaybeDropFrame(const scoped_refptr<media::VideoFrame>& frame); bool MaybeDropFrame(const scoped_refptr<media::VideoFrame>& frame,
float source_frame_rate);
// Bound to the IO-thread. // Bound to the IO-thread.
base::ThreadChecker io_thread_checker_; base::ThreadChecker io_thread_checker_;
...@@ -152,7 +153,7 @@ void VideoTrackAdapter::VideoFrameResolutionAdapter::DeliverFrame( ...@@ -152,7 +153,7 @@ void VideoTrackAdapter::VideoFrameResolutionAdapter::DeliverFrame(
const base::TimeTicks& estimated_capture_time) { const base::TimeTicks& estimated_capture_time) {
DCHECK(io_thread_checker_.CalledOnValidThread()); DCHECK(io_thread_checker_.CalledOnValidThread());
if (MaybeDropFrame(frame)) if (MaybeDropFrame(frame, format.frame_rate))
return; return;
// TODO(perkj): Allow cropping / scaling of textures once // TODO(perkj): Allow cropping / scaling of textures once
...@@ -224,8 +225,15 @@ void VideoTrackAdapter::VideoFrameResolutionAdapter::DeliverFrame( ...@@ -224,8 +225,15 @@ void VideoTrackAdapter::VideoFrameResolutionAdapter::DeliverFrame(
} }
bool VideoTrackAdapter::VideoFrameResolutionAdapter::MaybeDropFrame( bool VideoTrackAdapter::VideoFrameResolutionAdapter::MaybeDropFrame(
const scoped_refptr<media::VideoFrame>& frame) { const scoped_refptr<media::VideoFrame>& frame,
if (max_frame_rate_ == 0.0f) float source_frame_rate) {
DCHECK(io_thread_checker_.CalledOnValidThread());
// Do not drop frames if max frame rate hasn't been specified or the source
// frame rate is known and is lower than max.
if (max_frame_rate_ == 0.0f ||
(source_frame_rate > 0 &&
source_frame_rate <= max_frame_rate_))
return false; return false;
base::TimeDelta delta = frame->timestamp() - last_time_stamp_; base::TimeDelta delta = frame->timestamp() - last_time_stamp_;
...@@ -243,7 +251,7 @@ bool VideoTrackAdapter::VideoFrameResolutionAdapter::MaybeDropFrame( ...@@ -243,7 +251,7 @@ bool VideoTrackAdapter::VideoFrameResolutionAdapter::MaybeDropFrame(
return true; return true;
} }
last_time_stamp_ = frame->timestamp(); last_time_stamp_ = frame->timestamp();
if (delta == last_time_stamp_) // First received frame. if (delta == last_time_stamp_) // First received frame.
return false; return false;
// Calculate the frame rate using a simple AR filter. // Calculate the frame rate using a simple AR filter.
// Use a simple filter with 0.1 weight of the current sample. // Use a simple filter with 0.1 weight of the current sample.
......
...@@ -106,7 +106,7 @@ RemoteVideoSourceDelegate::RenderFrame( ...@@ -106,7 +106,7 @@ RemoteVideoSourceDelegate::RenderFrame(
media::VideoCaptureFormat format( media::VideoCaptureFormat format(
gfx::Size(video_frame->natural_size().width(), gfx::Size(video_frame->natural_size().width(),
video_frame->natural_size().height()), video_frame->natural_size().height()),
MediaStreamVideoSource::kDefaultFrameRate, MediaStreamVideoSource::kUnknownFrameRate,
pixel_format); pixel_format);
io_message_loop_->PostTask( io_message_loop_->PostTask(
......
...@@ -146,7 +146,7 @@ void PpFrameWriter::PutFrame(PPB_ImageData_Impl* image_data, ...@@ -146,7 +146,7 @@ void PpFrameWriter::PutFrame(PPB_ImageData_Impl* image_data,
gfx::Rect(frame_size), frame_size, timestamp); gfx::Rect(frame_size), frame_size, timestamp);
media::VideoCaptureFormat format( media::VideoCaptureFormat format(
frame_size, frame_size,
MediaStreamVideoSource::kDefaultFrameRate, MediaStreamVideoSource::kUnknownFrameRate,
media::PIXEL_FORMAT_YV12); media::PIXEL_FORMAT_YV12);
libyuv::BGRAToI420(reinterpret_cast<uint8*>(bitmap->getPixels()), libyuv::BGRAToI420(reinterpret_cast<uint8*>(bitmap->getPixels()),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment