| Index: content/renderer/media/gpu/rtc_video_encoder.cc
|
| diff --git a/content/renderer/media/gpu/rtc_video_encoder.cc b/content/renderer/media/gpu/rtc_video_encoder.cc
|
| index 7ec22b2f3d0a9996ed3ea0f422d9432e8c303567..7a9514e7f5cec07a8b0c76f65b48b8002c8999b0 100644
|
| --- a/content/renderer/media/gpu/rtc_video_encoder.cc
|
| +++ b/content/renderer/media/gpu/rtc_video_encoder.cc
|
| @@ -32,6 +32,9 @@ namespace content {
|
|
|
| namespace {
|
|
|
| +// Used for timestamp conversions.
|
| +static const int kMsToRtpTimestamp = 90;
|
| +
|
| // Translate from webrtc::VideoCodecType and webrtc::VideoCodec to
|
| // media::VideoCodecProfile.
|
| media::VideoCodecProfile WebRTCVideoCodecToVideoCodecProfile(
|
| @@ -486,8 +489,9 @@ void RTCVideoEncoder::Impl::BitstreamBufferReady(int32_t bitstream_buffer_id,
|
| capture_time_ms = capture_time_us / base::Time::kMicrosecondsPerMillisecond;
|
| }
|
| // RTP timestamp can wrap around. Get the lower 32 bits.
|
| - rtp_timestamp = static_cast<uint32_t>(
|
| - capture_time_us * 90 / base::Time::kMicrosecondsPerMillisecond);
|
| + rtp_timestamp =
|
| + static_cast<uint32_t>(capture_time_us * kMsToRtpTimestamp /
|
| + base::Time::kMicrosecondsPerMillisecond);
|
|
|
| webrtc::EncodedImage image(
|
| reinterpret_cast<uint8_t*>(output_buffer->memory()), payload_size,
|
| @@ -571,15 +575,13 @@ void RTCVideoEncoder::Impl::EncodeOneFrame() {
|
| }
|
|
|
| if (requires_copy) {
|
| - const base::TimeDelta timestamp =
|
| - frame ? frame->timestamp()
|
| - : base::TimeDelta::FromMilliseconds(next_frame->ntp_time_ms());
|
| base::SharedMemory* input_buffer = input_buffers_[index];
|
| frame = media::VideoFrame::WrapExternalSharedMemory(
|
| media::PIXEL_FORMAT_I420, input_frame_coded_size_,
|
| gfx::Rect(input_visible_size_), input_visible_size_,
|
| reinterpret_cast<uint8_t*>(input_buffer->memory()),
|
| - input_buffer->mapped_size(), input_buffer->handle(), 0, timestamp);
|
| + input_buffer->mapped_size(), input_buffer->handle(), 0,
|
| + base::TimeDelta());
|
| if (!frame.get()) {
|
| LogAndNotifyError(FROM_HERE, "failed to create frame",
|
| media::VideoEncodeAccelerator::kPlatformFailureError);
|
| @@ -606,6 +608,11 @@ void RTCVideoEncoder::Impl::EncodeOneFrame() {
|
| return;
|
| }
|
| }
|
| + // Use the timestamp set from WebRTC and convert it from 90 kHz.
|
| + frame->set_timestamp(
|
| + base::TimeDelta::FromMicroseconds(
|
| + next_frame->timestamp() * base::Time::kMicrosecondsPerMillisecond /
|
| + kMsToRtpTimestamp));
|
| frame->AddDestructionObserver(media::BindToCurrentLoop(
|
| base::Bind(&RTCVideoEncoder::Impl::EncodeFrameFinished, this, index)));
|
| video_encoder_->Encode(frame, next_frame_keyframe);
|
|
|