Added various timestamps to FrameObject.
Added various timestamps to the FrameObject class which are needed to calculate the jitter delay. BUG=webrtc:5514 Review-Url: https://codereview.webrtc.org/2124943002 Cr-Commit-Position: refs/heads/master@{#13434}
This commit is contained in:
@ -72,9 +72,15 @@ class VCMJitterEstimatorMock : public VCMJitterEstimator {
|
||||
bool incompleteFrame));
|
||||
};
|
||||
|
||||
class FrameObjectMock : public FrameObject {
|
||||
class FrameObjectFake : public FrameObject {
|
||||
public:
|
||||
MOCK_CONST_METHOD1(GetBitstream, bool(uint8_t* destination));
|
||||
bool GetBitstream(uint8_t* destination) const override { return true; }
|
||||
|
||||
uint32_t Timestamp() const override { return timestamp; }
|
||||
|
||||
int64_t ReceivedTime() const override { return 0; }
|
||||
|
||||
int64_t RenderTime() const override { return _renderTimeMs; }
|
||||
};
|
||||
|
||||
class TestFrameBuffer2 : public ::testing::Test {
|
||||
@ -113,7 +119,7 @@ class TestFrameBuffer2 : public ::testing::Test {
|
||||
"To many references specified for FrameObject.");
|
||||
std::array<uint16_t, sizeof...(refs)> references = {{refs...}};
|
||||
|
||||
std::unique_ptr<FrameObjectMock> frame(new FrameObjectMock());
|
||||
std::unique_ptr<FrameObjectFake> frame(new FrameObjectFake());
|
||||
frame->picture_id = picture_id;
|
||||
frame->spatial_layer = spatial_layer;
|
||||
frame->timestamp = ts_ms * 90;
|
||||
|
||||
@ -26,10 +26,12 @@ RtpFrameObject::RtpFrameObject(PacketBuffer* packet_buffer,
|
||||
uint16_t first_seq_num,
|
||||
uint16_t last_seq_num,
|
||||
size_t frame_size,
|
||||
int times_nacked)
|
||||
int times_nacked,
|
||||
int64_t received_time)
|
||||
: packet_buffer_(packet_buffer),
|
||||
first_seq_num_(first_seq_num),
|
||||
last_seq_num_(last_seq_num),
|
||||
received_time_(received_time),
|
||||
times_nacked_(times_nacked) {
|
||||
size = frame_size;
|
||||
VCMPacket* packet = packet_buffer_->GetPacket(first_seq_num);
|
||||
@ -84,6 +86,18 @@ bool RtpFrameObject::GetBitstream(uint8_t* destination) const {
|
||||
return packet_buffer_->GetBitstream(*this, destination);
|
||||
}
|
||||
|
||||
uint32_t RtpFrameObject::Timestamp() const {
|
||||
return timestamp_;
|
||||
}
|
||||
|
||||
int64_t RtpFrameObject::ReceivedTime() const {
|
||||
return received_time_;
|
||||
}
|
||||
|
||||
int64_t RtpFrameObject::RenderTime() const {
|
||||
return _renderTimeMs;
|
||||
}
|
||||
|
||||
RTPVideoTypeHeader* RtpFrameObject::GetCodecHeader() const {
|
||||
VCMPacket* packet = packet_buffer_->GetPacket(first_seq_num_);
|
||||
if (!packet)
|
||||
|
||||
@ -23,9 +23,19 @@ class FrameObject : public webrtc::VCMEncodedFrame {
|
||||
static const uint8_t kMaxFrameReferences = 5;
|
||||
|
||||
FrameObject();
|
||||
virtual ~FrameObject() {}
|
||||
|
||||
virtual bool GetBitstream(uint8_t* destination) const = 0;
|
||||
virtual ~FrameObject() {}
|
||||
|
||||
// The capture timestamp of this frame.
|
||||
virtual uint32_t Timestamp() const = 0;
|
||||
|
||||
// When this frame was received.
|
||||
virtual int64_t ReceivedTime() const = 0;
|
||||
|
||||
// When this frame should be rendered.
|
||||
virtual int64_t RenderTime() const = 0;
|
||||
|
||||
|
||||
// The tuple (|picture_id|, |spatial_layer|) uniquely identifies a frame
|
||||
// object. For codec types that don't necessarily have picture ids they
|
||||
@ -49,7 +59,8 @@ class RtpFrameObject : public FrameObject {
|
||||
uint16_t first_seq_num,
|
||||
uint16_t last_seq_num,
|
||||
size_t frame_size,
|
||||
int times_nacked);
|
||||
int times_nacked,
|
||||
int64_t received_time);
|
||||
|
||||
~RtpFrameObject();
|
||||
uint16_t first_seq_num() const;
|
||||
@ -58,6 +69,9 @@ class RtpFrameObject : public FrameObject {
|
||||
enum FrameType frame_type() const;
|
||||
VideoCodecType codec_type() const;
|
||||
bool GetBitstream(uint8_t* destination) const override;
|
||||
uint32_t Timestamp() const override;
|
||||
int64_t ReceivedTime() const override;
|
||||
int64_t RenderTime() const override;
|
||||
RTPVideoTypeHeader* GetCodecHeader() const;
|
||||
|
||||
private:
|
||||
@ -66,6 +80,8 @@ class RtpFrameObject : public FrameObject {
|
||||
VideoCodecType codec_type_;
|
||||
uint16_t first_seq_num_;
|
||||
uint16_t last_seq_num_;
|
||||
uint32_t timestamp_;
|
||||
int64_t received_time_;
|
||||
|
||||
// Equal to times nacked of the packet with the highet times nacked
|
||||
// belonging to this frame.
|
||||
|
||||
@ -16,14 +16,17 @@
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/modules/video_coding/frame_object.h"
|
||||
#include "webrtc/system_wrappers/include/clock.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace video_coding {
|
||||
|
||||
PacketBuffer::PacketBuffer(size_t start_buffer_size,
|
||||
PacketBuffer::PacketBuffer(Clock* clock,
|
||||
size_t start_buffer_size,
|
||||
size_t max_buffer_size,
|
||||
OnCompleteFrameCallback* frame_callback)
|
||||
: size_(start_buffer_size),
|
||||
: clock_(clock),
|
||||
size_(start_buffer_size),
|
||||
max_size_(max_buffer_size),
|
||||
first_seq_num_(0),
|
||||
last_seq_num_(0),
|
||||
@ -163,8 +166,9 @@ void PacketBuffer::FindFrames(uint16_t seq_num) {
|
||||
start_seq_num--;
|
||||
}
|
||||
|
||||
std::unique_ptr<RtpFrameObject> frame(new RtpFrameObject(
|
||||
this, start_seq_num, seq_num, frame_size, max_nack_count));
|
||||
std::unique_ptr<RtpFrameObject> frame(
|
||||
new RtpFrameObject(this, start_seq_num, seq_num, frame_size,
|
||||
max_nack_count, clock_->TimeInMilliseconds()));
|
||||
reference_finder_.ManageFrame(std::move(frame));
|
||||
}
|
||||
|
||||
|
||||
@ -21,6 +21,9 @@
|
||||
#include "webrtc/modules/video_coding/sequence_number_util.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class Clock;
|
||||
|
||||
namespace video_coding {
|
||||
|
||||
class FrameObject;
|
||||
@ -35,7 +38,8 @@ class OnCompleteFrameCallback {
|
||||
class PacketBuffer {
|
||||
public:
|
||||
// Both |start_buffer_size| and |max_buffer_size| must be a power of 2.
|
||||
PacketBuffer(size_t start_buffer_size,
|
||||
PacketBuffer(Clock* clock,
|
||||
size_t start_buffer_size,
|
||||
size_t max_buffer_size,
|
||||
OnCompleteFrameCallback* frame_callback);
|
||||
|
||||
@ -68,6 +72,8 @@ class PacketBuffer {
|
||||
bool frame_created = false;
|
||||
};
|
||||
|
||||
Clock* const clock_;
|
||||
|
||||
// Tries to expand the buffer.
|
||||
bool ExpandBufferSize() EXCLUSIVE_LOCKS_REQUIRED(crit_);
|
||||
|
||||
|
||||
@ -14,11 +14,11 @@
|
||||
#include <set>
|
||||
#include <utility>
|
||||
|
||||
#include "webrtc/modules/video_coding/frame_object.h"
|
||||
#include "webrtc/modules/video_coding/packet_buffer.h"
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/base/random.h"
|
||||
#include "webrtc/modules/video_coding/frame_object.h"
|
||||
#include "webrtc/modules/video_coding/packet_buffer.h"
|
||||
#include "webrtc/system_wrappers/include/clock.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace video_coding {
|
||||
@ -28,7 +28,11 @@ class TestPacketBuffer : public ::testing::Test,
|
||||
protected:
|
||||
TestPacketBuffer()
|
||||
: rand_(0x8739211),
|
||||
packet_buffer_(new PacketBuffer(kStartSize, kMaxSize, this)),
|
||||
clock_(new SimulatedClock(0)),
|
||||
packet_buffer_(new PacketBuffer(clock_.get(),
|
||||
kStartSize,
|
||||
kMaxSize,
|
||||
this)),
|
||||
frames_from_callback_(FrameComp()),
|
||||
dummy_data_(new uint8_t[kDummyDataSize]()) {}
|
||||
|
||||
@ -248,6 +252,7 @@ class TestPacketBuffer : public ::testing::Test,
|
||||
const int kDummyDataSize = 4;
|
||||
|
||||
Random rand_;
|
||||
std::unique_ptr<Clock> clock_;
|
||||
std::unique_ptr<PacketBuffer> packet_buffer_;
|
||||
struct FrameComp {
|
||||
bool operator()(const std::pair<uint16_t, uint8_t> f1,
|
||||
@ -929,7 +934,7 @@ TEST_F(TestPacketBuffer, Vp8LayerSync) {
|
||||
}
|
||||
|
||||
TEST_F(TestPacketBuffer, Vp8InsertLargeFrames) {
|
||||
packet_buffer_.reset(new PacketBuffer(1 << 3, 1 << 12, this));
|
||||
packet_buffer_.reset(new PacketBuffer(clock_.get(), 1 << 3, 1 << 12, this));
|
||||
uint16_t pid = Rand();
|
||||
uint16_t seq_num = Rand();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user