Commit 10d7f9e6 authored by emircan's avatar emircan Committed by Commit bot

Correct frame timestamps in VTVideoEncodeAccelerator

This CL corrects the timestamp sent with the encoded frame data from
VTVideoEncodeAccelerator. Recently, this functionality is added to the
VEA interface and we can use the frame's original capture timestamp.

BUG=350106
TEST=AppRTC loopback in Macbook Air.

Review-Url: https://codereview.chromium.org/2039423002
Cr-Commit-Position: refs/heads/master@{#398187}
parent c8cb7cbd
...@@ -42,10 +42,15 @@ struct VTVideoEncodeAccelerator::InProgressFrameEncode { ...@@ -42,10 +42,15 @@ struct VTVideoEncodeAccelerator::InProgressFrameEncode {
}; };
struct VTVideoEncodeAccelerator::EncodeOutput { struct VTVideoEncodeAccelerator::EncodeOutput {
EncodeOutput(VTEncodeInfoFlags info_flags, CMSampleBufferRef sbuf) EncodeOutput(VTEncodeInfoFlags info_flags,
: info(info_flags), sample_buffer(sbuf, base::scoped_policy::RETAIN) {} CMSampleBufferRef sbuf,
base::TimeDelta timestamp)
: info(info_flags),
sample_buffer(sbuf, base::scoped_policy::RETAIN),
capture_timestamp(timestamp) {}
const VTEncodeInfoFlags info; const VTEncodeInfoFlags info;
const base::ScopedCFTypeRef<CMSampleBufferRef> sample_buffer; const base::ScopedCFTypeRef<CMSampleBufferRef> sample_buffer;
const base::TimeDelta capture_timestamp;
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(EncodeOutput); DISALLOW_IMPLICIT_CONSTRUCTORS(EncodeOutput);
...@@ -393,15 +398,14 @@ void VTVideoEncodeAccelerator::CompressionCallback(void* encoder_opaque, ...@@ -393,15 +398,14 @@ void VTVideoEncodeAccelerator::CompressionCallback(void* encoder_opaque,
auto encoder = reinterpret_cast<VTVideoEncodeAccelerator*>(encoder_opaque); auto encoder = reinterpret_cast<VTVideoEncodeAccelerator*>(encoder_opaque);
DCHECK(encoder); DCHECK(encoder);
// Release InProgressFrameEncode, since we don't have support to return // InProgressFrameEncode holds timestamp information of the encoded frame.
// timestamps at this point. std::unique_ptr<InProgressFrameEncode> frame_info(
std::unique_ptr<InProgressFrameEncode> request(
reinterpret_cast<InProgressFrameEncode*>(request_opaque)); reinterpret_cast<InProgressFrameEncode*>(request_opaque));
request.reset();
// EncodeOutput holds onto CMSampleBufferRef when posting task between // EncodeOutput holds onto CMSampleBufferRef when posting task between
// threads. // threads.
std::unique_ptr<EncodeOutput> encode_output(new EncodeOutput(info, sbuf)); std::unique_ptr<EncodeOutput> encode_output(
new EncodeOutput(info, sbuf, frame_info->timestamp));
// This method is NOT called on |encoder_thread_|, so we still need to // This method is NOT called on |encoder_thread_|, so we still need to
// post a task back to it to do work. // post a task back to it to do work.
...@@ -446,7 +450,7 @@ void VTVideoEncodeAccelerator::ReturnBitstreamBuffer( ...@@ -446,7 +450,7 @@ void VTVideoEncodeAccelerator::ReturnBitstreamBuffer(
client_task_runner_->PostTask( client_task_runner_->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(&Client::BitstreamBufferReady, client_, buffer_ref->id, 0, base::Bind(&Client::BitstreamBufferReady, client_, buffer_ref->id, 0,
false, base::Time::Now() - base::Time())); false, encode_output->capture_timestamp));
return; return;
} }
...@@ -470,7 +474,7 @@ void VTVideoEncodeAccelerator::ReturnBitstreamBuffer( ...@@ -470,7 +474,7 @@ void VTVideoEncodeAccelerator::ReturnBitstreamBuffer(
client_task_runner_->PostTask( client_task_runner_->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(&Client::BitstreamBufferReady, client_, buffer_ref->id, base::Bind(&Client::BitstreamBufferReady, client_, buffer_ref->id,
used_buffer_size, keyframe, base::Time::Now() - base::Time())); used_buffer_size, keyframe, encode_output->capture_timestamp));
} }
bool VTVideoEncodeAccelerator::ResetCompressionSession() { bool VTVideoEncodeAccelerator::ResetCompressionSession() {
......
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