diff options
author | miu <miu@chromium.org> | 2015-12-29 14:04:57 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-29 22:05:47 +0000 |
commit | c938d4441a3fe1c3851858fba68e017aef424f86 (patch) | |
tree | 23e28f1f3d971c79c60e62411e18fb7725998a52 /media/cast/logging | |
parent | 54342454be5d73c64aa47b57facd880ba8df2b36 (diff) | |
download | chromium_src-c938d4441a3fe1c3851858fba68e017aef424f86.zip chromium_src-c938d4441a3fe1c3851858fba68e017aef424f86.tar.gz chromium_src-c938d4441a3fe1c3851858fba68e017aef424f86.tar.bz2 |
Replace uses of raw uint32's with a type-checked RtpTimeTicks data type.
Introduces RtpTimeDelta and RtpTimeTicks to media::cast, modeled after
base::TimeDelta and base::TimeTicks, that track RTP time and provide a
strict set of valid math and comparison operators, bit truncation and
re-expansion, and timebase conversion.
All instances of raw uint32 used to represent RTP timestamps has been
replaced with the new data type.
BUG=530839
NOPRESUBMIT=true
Review URL: https://codereview.chromium.org/1515433002
Cr-Commit-Position: refs/heads/master@{#367106}
Diffstat (limited to 'media/cast/logging')
-rw-r--r-- | media/cast/logging/encoding_event_subscriber.cc | 36 | ||||
-rw-r--r-- | media/cast/logging/encoding_event_subscriber.h | 12 | ||||
-rw-r--r-- | media/cast/logging/encoding_event_subscriber_unittest.cc | 99 | ||||
-rw-r--r-- | media/cast/logging/log_deserializer.cc | 27 | ||||
-rw-r--r-- | media/cast/logging/log_deserializer.h | 8 | ||||
-rw-r--r-- | media/cast/logging/log_serializer.cc | 21 | ||||
-rw-r--r-- | media/cast/logging/logging_defines.cc | 15 | ||||
-rw-r--r-- | media/cast/logging/logging_defines.h | 7 | ||||
-rw-r--r-- | media/cast/logging/receiver_time_offset_estimator_impl.cc | 24 | ||||
-rw-r--r-- | media/cast/logging/receiver_time_offset_estimator_impl.h | 6 | ||||
-rw-r--r-- | media/cast/logging/receiver_time_offset_estimator_impl_unittest.cc | 12 | ||||
-rw-r--r-- | media/cast/logging/simple_event_subscriber_unittest.cc | 10 | ||||
-rw-r--r-- | media/cast/logging/stats_event_subscriber.cc | 6 | ||||
-rw-r--r-- | media/cast/logging/stats_event_subscriber.h | 6 | ||||
-rw-r--r-- | media/cast/logging/stats_event_subscriber_unittest.cc | 26 |
15 files changed, 169 insertions, 146 deletions
diff --git a/media/cast/logging/encoding_event_subscriber.cc b/media/cast/logging/encoding_event_subscriber.cc index fa3310d..27e9405 100644 --- a/media/cast/logging/encoding_event_subscriber.cc +++ b/media/cast/logging/encoding_event_subscriber.cc @@ -51,12 +51,9 @@ namespace cast { EncodingEventSubscriber::EncodingEventSubscriber( EventMediaType event_media_type, size_t max_frames) - : event_media_type_(event_media_type), - max_frames_(max_frames), - frame_event_storage_index_(0), - packet_event_storage_index_(0), - seen_first_rtp_timestamp_(false), - first_rtp_timestamp_(0u) {} + : event_media_type_(event_media_type), max_frames_(max_frames) { + Reset(); +} EncodingEventSubscriber::~EncodingEventSubscriber() { DCHECK(thread_checker_.CalledOnValidThread()); @@ -69,7 +66,7 @@ void EncodingEventSubscriber::OnReceiveFrameEvent( if (event_media_type_ != frame_event.media_type) return; - RtpTimestamp relative_rtp_timestamp = + const RtpTimeDelta relative_rtp_timestamp = GetRelativeRtpTimestamp(frame_event.rtp_timestamp); FrameEventMap::iterator it = frame_event_map_.find(relative_rtp_timestamp); linked_ptr<AggregatedFrameEvent> event_proto; @@ -77,7 +74,8 @@ void EncodingEventSubscriber::OnReceiveFrameEvent( // Look up existing entry. If not found, create a new entry and add to map. if (it == frame_event_map_.end()) { event_proto.reset(new AggregatedFrameEvent); - event_proto->set_relative_rtp_timestamp(relative_rtp_timestamp); + event_proto->set_relative_rtp_timestamp( + relative_rtp_timestamp.lower_32_bits()); frame_event_map_.insert( std::make_pair(relative_rtp_timestamp, event_proto)); } else { @@ -87,7 +85,8 @@ void EncodingEventSubscriber::OnReceiveFrameEvent( << ". Using new frame event proto."; AddFrameEventToStorage(event_proto); event_proto.reset(new AggregatedFrameEvent); - event_proto->set_relative_rtp_timestamp(relative_rtp_timestamp); + event_proto->set_relative_rtp_timestamp( + relative_rtp_timestamp.lower_32_bits()); it->second = event_proto; } } @@ -136,7 +135,7 @@ void EncodingEventSubscriber::OnReceivePacketEvent( if (event_media_type_ != packet_event.media_type) return; - RtpTimestamp relative_rtp_timestamp = + const RtpTimeDelta relative_rtp_timestamp = GetRelativeRtpTimestamp(packet_event.rtp_timestamp); PacketEventMap::iterator it = packet_event_map_.find(relative_rtp_timestamp); @@ -146,7 +145,8 @@ void EncodingEventSubscriber::OnReceivePacketEvent( // Look up existing entry. If not found, create a new entry and add to map. if (it == packet_event_map_.end()) { event_proto.reset(new AggregatedPacketEvent); - event_proto->set_relative_rtp_timestamp(relative_rtp_timestamp); + event_proto->set_relative_rtp_timestamp( + relative_rtp_timestamp.lower_32_bits()); packet_event_map_.insert( std::make_pair(relative_rtp_timestamp, event_proto)); base_packet_event_proto = GetNewBasePacketEvent( @@ -173,7 +173,8 @@ void EncodingEventSubscriber::OnReceivePacketEvent( << "Using new packet event proto."; AddPacketEventToStorage(event_proto); event_proto.reset(new AggregatedPacketEvent); - event_proto->set_relative_rtp_timestamp(relative_rtp_timestamp); + event_proto->set_relative_rtp_timestamp( + relative_rtp_timestamp.lower_32_bits()); it->second = event_proto; } @@ -186,7 +187,8 @@ void EncodingEventSubscriber::OnReceivePacketEvent( << packet_event.packet_id << ". Using new packet event proto."; AddPacketEventToStorage(event_proto); event_proto.reset(new AggregatedPacketEvent); - event_proto->set_relative_rtp_timestamp(relative_rtp_timestamp); + event_proto->set_relative_rtp_timestamp( + relative_rtp_timestamp.lower_32_bits()); it->second = event_proto; base_packet_event_proto = GetNewBasePacketEvent( event_proto.get(), packet_event.packet_id, packet_event.size); @@ -225,7 +227,7 @@ void EncodingEventSubscriber::GetEventsAndReset(LogMetadata* metadata, &IsRtpTimestampLessThan<linked_ptr<AggregatedPacketEvent> >); metadata->set_is_audio(event_media_type_ == AUDIO_EVENT); - metadata->set_first_rtp_timestamp(first_rtp_timestamp_); + metadata->set_first_rtp_timestamp(first_rtp_timestamp_.lower_32_bits()); metadata->set_num_frame_events(frame_event_storage_.size()); metadata->set_num_packet_events(packet_event_storage_.size()); metadata->set_reference_timestamp_ms_at_unix_epoch( @@ -280,8 +282,8 @@ void EncodingEventSubscriber::AddPacketEventToStorage( packet_event_storage_index_ = (packet_event_storage_index_ + 1) % max_frames_; } -RtpTimestamp EncodingEventSubscriber::GetRelativeRtpTimestamp( - RtpTimestamp rtp_timestamp) { +RtpTimeDelta EncodingEventSubscriber::GetRelativeRtpTimestamp( + RtpTimeTicks rtp_timestamp) { if (!seen_first_rtp_timestamp_) { seen_first_rtp_timestamp_ = true; first_rtp_timestamp_ = rtp_timestamp; @@ -298,7 +300,7 @@ void EncodingEventSubscriber::Reset() { packet_event_storage_.clear(); packet_event_storage_index_ = 0; seen_first_rtp_timestamp_ = false; - first_rtp_timestamp_ = 0u; + first_rtp_timestamp_ = RtpTimeTicks(); } } // namespace cast diff --git a/media/cast/logging/encoding_event_subscriber.h b/media/cast/logging/encoding_event_subscriber.h index a6790d0..ba077c0 100644 --- a/media/cast/logging/encoding_event_subscriber.h +++ b/media/cast/logging/encoding_event_subscriber.h @@ -68,11 +68,11 @@ class EncodingEventSubscriber : public RawEventSubscriber { PacketEventList* packet_events); private: - typedef std::map<RtpTimestamp, - linked_ptr<media::cast::proto::AggregatedFrameEvent> > + typedef std::map<RtpTimeDelta, + linked_ptr<media::cast::proto::AggregatedFrameEvent>> FrameEventMap; - typedef std::map<RtpTimestamp, - linked_ptr<media::cast::proto::AggregatedPacketEvent> > + typedef std::map<RtpTimeDelta, + linked_ptr<media::cast::proto::AggregatedPacketEvent>> PacketEventMap; // Transfer up to |max_num_entries| smallest entries from |frame_event_map_| @@ -91,7 +91,7 @@ class EncodingEventSubscriber : public RawEventSubscriber { // Returns the difference between |rtp_timestamp| and |first_rtp_timestamp_|. // Sets |first_rtp_timestamp_| if it is not already set. - RtpTimestamp GetRelativeRtpTimestamp(RtpTimestamp rtp_timestamp); + RtpTimeDelta GetRelativeRtpTimestamp(RtpTimeTicks rtp_timestamp); // Clears the maps and first RTP timestamp seen. void Reset(); @@ -114,7 +114,7 @@ class EncodingEventSubscriber : public RawEventSubscriber { bool seen_first_rtp_timestamp_; // Set to RTP timestamp of first event encountered after a |Reset()|. - RtpTimestamp first_rtp_timestamp_; + RtpTimeTicks first_rtp_timestamp_; DISALLOW_COPY_AND_ASSIGN(EncodingEventSubscriber); }; diff --git a/media/cast/logging/encoding_event_subscriber_unittest.cc b/media/cast/logging/encoding_event_subscriber_unittest.cc index 6d6dcb3..6d711ff 100644 --- a/media/cast/logging/encoding_event_subscriber_unittest.cc +++ b/media/cast/logging/encoding_event_subscriber_unittest.cc @@ -41,8 +41,7 @@ class EncodingEventSubscriberTest : public ::testing::Test { new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_), task_runner_, task_runner_, - task_runner_)), - first_rtp_timestamp_(0) {} + task_runner_)) {} void Init(EventMediaType event_media_type) { DCHECK(!event_subscriber_); @@ -58,7 +57,8 @@ class EncodingEventSubscriberTest : public ::testing::Test { void GetEventsAndReset() { event_subscriber_->GetEventsAndReset( &metadata_, &frame_events_, &packet_events_); - first_rtp_timestamp_ = metadata_.first_rtp_timestamp(); + first_rtp_timestamp_ = + RtpTimeTicks().Expand(metadata_.first_rtp_timestamp()); } base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment. @@ -68,7 +68,7 @@ class EncodingEventSubscriberTest : public ::testing::Test { FrameEventList frame_events_; PacketEventList packet_events_; LogMetadata metadata_; - RtpTimestamp first_rtp_timestamp_; + RtpTimeTicks first_rtp_timestamp_; }; TEST_F(EncodingEventSubscriberTest, FrameEventTruncating) { @@ -84,7 +84,8 @@ TEST_F(EncodingEventSubscriberTest, FrameEventTruncating) { capture_begin_event->timestamp = now; capture_begin_event->type = FRAME_CAPTURE_BEGIN; capture_begin_event->media_type = VIDEO_EVENT; - capture_begin_event->rtp_timestamp = i * 100; + capture_begin_event->rtp_timestamp = + RtpTimeTicks().Expand<uint32_t>(i * 100); cast_environment_->logger()->DispatchFrameEvent( std::move(capture_begin_event)); @@ -92,7 +93,7 @@ TEST_F(EncodingEventSubscriberTest, FrameEventTruncating) { capture_end_event->timestamp = now; capture_end_event->type = FRAME_CAPTURE_END; capture_end_event->media_type = VIDEO_EVENT; - capture_end_event->rtp_timestamp = i * 100; + capture_end_event->rtp_timestamp = RtpTimeTicks().Expand<uint32_t>(i * 100); capture_end_event->width = width; capture_end_event->height = height; cast_environment_->logger()->DispatchFrameEvent( @@ -102,7 +103,7 @@ TEST_F(EncodingEventSubscriberTest, FrameEventTruncating) { decoded_event->timestamp = now; decoded_event->type = FRAME_DECODED; decoded_event->media_type = VIDEO_EVENT; - decoded_event->rtp_timestamp = i * 100; + decoded_event->rtp_timestamp = RtpTimeTicks().Expand<uint32_t>(i * 100); decoded_event->frame_id = 0; cast_environment_->logger()->DispatchFrameEvent(std::move(decoded_event)); @@ -136,7 +137,7 @@ TEST_F(EncodingEventSubscriberTest, PacketEventTruncating) { receive_event->timestamp = now; receive_event->type = PACKET_RECEIVED; receive_event->media_type = AUDIO_EVENT; - receive_event->rtp_timestamp = i * 100; + receive_event->rtp_timestamp = RtpTimeTicks().Expand<uint32_t>(i * 100); receive_event->frame_id = 0; receive_event->packet_id = i; receive_event->max_packet_id = 10; @@ -155,7 +156,7 @@ TEST_F(EncodingEventSubscriberTest, EventFiltering) { Init(VIDEO_EVENT); base::TimeTicks now(testing_clock_->NowTicks()); - RtpTimestamp rtp_timestamp = 100; + RtpTimeTicks rtp_timestamp = RtpTimeTicks().Expand(UINT32_C(100)); scoped_ptr<FrameEvent> video_event(new FrameEvent()); video_event->timestamp = now; video_event->type = FRAME_DECODED; @@ -192,7 +193,7 @@ TEST_F(EncodingEventSubscriberTest, EventFiltering) { TEST_F(EncodingEventSubscriberTest, FrameEvent) { Init(VIDEO_EVENT); base::TimeTicks now(testing_clock_->NowTicks()); - RtpTimestamp rtp_timestamp = 100; + RtpTimeTicks rtp_timestamp = RtpTimeTicks().Expand(UINT32_C(100)); scoped_ptr<FrameEvent> decode_event(new FrameEvent()); decode_event->timestamp = now; decode_event->type = FRAME_DECODED; @@ -205,12 +206,12 @@ TEST_F(EncodingEventSubscriberTest, FrameEvent) { ASSERT_EQ(1u, frame_events_.size()); - RtpTimestamp relative_rtp_timestamp = rtp_timestamp - first_rtp_timestamp_; FrameEventList::iterator it = frame_events_.begin(); linked_ptr<AggregatedFrameEvent> event = *it; - EXPECT_EQ(relative_rtp_timestamp, event->relative_rtp_timestamp()); + EXPECT_EQ((rtp_timestamp - first_rtp_timestamp_).lower_32_bits(), + event->relative_rtp_timestamp()); ASSERT_EQ(1, event->event_type_size()); EXPECT_EQ(media::cast::proto::FRAME_DECODED, event->event_type(0)); @@ -227,7 +228,7 @@ TEST_F(EncodingEventSubscriberTest, FrameEvent) { TEST_F(EncodingEventSubscriberTest, FrameEventDelay) { Init(AUDIO_EVENT); base::TimeTicks now(testing_clock_->NowTicks()); - RtpTimestamp rtp_timestamp = 100; + RtpTimeTicks rtp_timestamp = RtpTimeTicks().Expand(UINT32_C(100)); int delay_ms = 100; scoped_ptr<FrameEvent> playout_event(new FrameEvent()); playout_event->timestamp = now; @@ -242,12 +243,12 @@ TEST_F(EncodingEventSubscriberTest, FrameEventDelay) { ASSERT_EQ(1u, frame_events_.size()); - RtpTimestamp relative_rtp_timestamp = rtp_timestamp - first_rtp_timestamp_; FrameEventList::iterator it = frame_events_.begin(); linked_ptr<AggregatedFrameEvent> event = *it; - EXPECT_EQ(relative_rtp_timestamp, event->relative_rtp_timestamp()); + EXPECT_EQ((rtp_timestamp - first_rtp_timestamp_).lower_32_bits(), + event->relative_rtp_timestamp()); ASSERT_EQ(1, event->event_type_size()); EXPECT_EQ(media::cast::proto::FRAME_PLAYOUT, event->event_type(0)); @@ -262,7 +263,7 @@ TEST_F(EncodingEventSubscriberTest, FrameEventDelay) { TEST_F(EncodingEventSubscriberTest, FrameEventSize) { Init(VIDEO_EVENT); base::TimeTicks now(testing_clock_->NowTicks()); - RtpTimestamp rtp_timestamp = 100; + RtpTimeTicks rtp_timestamp = RtpTimeTicks().Expand(UINT32_C(100)); int size = 123; bool key_frame = true; int target_bitrate = 1024; @@ -285,12 +286,12 @@ TEST_F(EncodingEventSubscriberTest, FrameEventSize) { ASSERT_EQ(1u, frame_events_.size()); - RtpTimestamp relative_rtp_timestamp = rtp_timestamp - first_rtp_timestamp_; FrameEventList::iterator it = frame_events_.begin(); linked_ptr<AggregatedFrameEvent> event = *it; - EXPECT_EQ(relative_rtp_timestamp, event->relative_rtp_timestamp()); + EXPECT_EQ((rtp_timestamp - first_rtp_timestamp_).lower_32_bits(), + event->relative_rtp_timestamp()); ASSERT_EQ(1, event->event_type_size()); EXPECT_EQ(media::cast::proto::FRAME_ENCODED, event->event_type(0)); @@ -308,8 +309,8 @@ TEST_F(EncodingEventSubscriberTest, FrameEventSize) { TEST_F(EncodingEventSubscriberTest, MultipleFrameEvents) { Init(AUDIO_EVENT); - RtpTimestamp rtp_timestamp1 = 100; - RtpTimestamp rtp_timestamp2 = 200; + RtpTimeTicks rtp_timestamp1 = RtpTimeTicks().Expand(UINT32_C(100)); + RtpTimeTicks rtp_timestamp2 = rtp_timestamp1.Expand(UINT32_C(200)); base::TimeTicks now1(testing_clock_->NowTicks()); scoped_ptr<FrameEvent> playout_event(new FrameEvent()); playout_event->timestamp = now1; @@ -347,12 +348,12 @@ TEST_F(EncodingEventSubscriberTest, MultipleFrameEvents) { ASSERT_EQ(2u, frame_events_.size()); - RtpTimestamp relative_rtp_timestamp = rtp_timestamp1 - first_rtp_timestamp_; FrameEventList::iterator it = frame_events_.begin(); linked_ptr<AggregatedFrameEvent> event = *it; - EXPECT_EQ(relative_rtp_timestamp, event->relative_rtp_timestamp()); + EXPECT_EQ((rtp_timestamp1 - first_rtp_timestamp_).lower_32_bits(), + event->relative_rtp_timestamp()); ASSERT_EQ(2, event->event_type_size()); EXPECT_EQ(media::cast::proto::FRAME_PLAYOUT, event->event_type(0)); @@ -364,12 +365,12 @@ TEST_F(EncodingEventSubscriberTest, MultipleFrameEvents) { EXPECT_FALSE(event->has_key_frame()); - relative_rtp_timestamp = rtp_timestamp2 - first_rtp_timestamp_; ++it; event = *it; - EXPECT_EQ(relative_rtp_timestamp, event->relative_rtp_timestamp()); + EXPECT_EQ((rtp_timestamp2 - first_rtp_timestamp_).lower_32_bits(), + event->relative_rtp_timestamp()); ASSERT_EQ(1, event->event_type_size()); EXPECT_EQ(media::cast::proto::FRAME_ENCODED, event->event_type(0)); @@ -385,7 +386,7 @@ TEST_F(EncodingEventSubscriberTest, MultipleFrameEvents) { TEST_F(EncodingEventSubscriberTest, PacketEvent) { Init(AUDIO_EVENT); base::TimeTicks now(testing_clock_->NowTicks()); - RtpTimestamp rtp_timestamp = 100; + RtpTimeTicks rtp_timestamp = RtpTimeTicks().Expand(UINT32_C(100)); int packet_id = 2; int size = 100; scoped_ptr<PacketEvent> receive_event(new PacketEvent()); @@ -403,12 +404,12 @@ TEST_F(EncodingEventSubscriberTest, PacketEvent) { ASSERT_EQ(1u, packet_events_.size()); - RtpTimestamp relative_rtp_timestamp = rtp_timestamp - first_rtp_timestamp_; PacketEventList::iterator it = packet_events_.begin(); linked_ptr<AggregatedPacketEvent> event = *it; - EXPECT_EQ(relative_rtp_timestamp, event->relative_rtp_timestamp()); + EXPECT_EQ((rtp_timestamp - first_rtp_timestamp_).lower_32_bits(), + event->relative_rtp_timestamp()); ASSERT_EQ(1, event->base_packet_event_size()); const BasePacketEvent& base_event = event->base_packet_event(0); @@ -427,7 +428,7 @@ TEST_F(EncodingEventSubscriberTest, PacketEvent) { TEST_F(EncodingEventSubscriberTest, MultiplePacketEventsForPacket) { Init(VIDEO_EVENT); base::TimeTicks now1(testing_clock_->NowTicks()); - RtpTimestamp rtp_timestamp = 100; + RtpTimeTicks rtp_timestamp = RtpTimeTicks().Expand(UINT32_C(100)); int packet_id = 2; int size = 100; scoped_ptr<PacketEvent> send_event(new PacketEvent()); @@ -458,12 +459,12 @@ TEST_F(EncodingEventSubscriberTest, MultiplePacketEventsForPacket) { ASSERT_EQ(1u, packet_events_.size()); - RtpTimestamp relative_rtp_timestamp = rtp_timestamp - first_rtp_timestamp_; PacketEventList::iterator it = packet_events_.begin(); linked_ptr<AggregatedPacketEvent> event = *it; - EXPECT_EQ(relative_rtp_timestamp, event->relative_rtp_timestamp()); + EXPECT_EQ((rtp_timestamp - first_rtp_timestamp_).lower_32_bits(), + event->relative_rtp_timestamp()); ASSERT_EQ(1, event->base_packet_event_size()); const BasePacketEvent& base_event = event->base_packet_event(0); @@ -481,7 +482,7 @@ TEST_F(EncodingEventSubscriberTest, MultiplePacketEventsForPacket) { TEST_F(EncodingEventSubscriberTest, MultiplePacketEventsForFrame) { Init(VIDEO_EVENT); base::TimeTicks now1(testing_clock_->NowTicks()); - RtpTimestamp rtp_timestamp = 100; + RtpTimeTicks rtp_timestamp = RtpTimeTicks().Expand(UINT32_C(100)); int packet_id_1 = 2; int packet_id_2 = 3; int size = 100; @@ -513,12 +514,12 @@ TEST_F(EncodingEventSubscriberTest, MultiplePacketEventsForFrame) { ASSERT_EQ(1u, packet_events_.size()); - RtpTimestamp relative_rtp_timestamp = rtp_timestamp - first_rtp_timestamp_; PacketEventList::iterator it = packet_events_.begin(); linked_ptr<AggregatedPacketEvent> event = *it; - EXPECT_EQ(relative_rtp_timestamp, event->relative_rtp_timestamp()); + EXPECT_EQ((rtp_timestamp - first_rtp_timestamp_).lower_32_bits(), + event->relative_rtp_timestamp()); ASSERT_EQ(2, event->base_packet_event_size()); const BasePacketEvent& base_event = event->base_packet_event(0); @@ -541,8 +542,8 @@ TEST_F(EncodingEventSubscriberTest, MultiplePacketEventsForFrame) { TEST_F(EncodingEventSubscriberTest, MultiplePacketEvents) { Init(VIDEO_EVENT); base::TimeTicks now1(testing_clock_->NowTicks()); - RtpTimestamp rtp_timestamp_1 = 100; - RtpTimestamp rtp_timestamp_2 = 200; + RtpTimeTicks rtp_timestamp_1 = RtpTimeTicks().Expand(UINT32_C(100)); + RtpTimeTicks rtp_timestamp_2 = rtp_timestamp_1.Expand(UINT32_C(200)); int packet_id_1 = 2; int packet_id_2 = 3; int size = 100; @@ -574,12 +575,12 @@ TEST_F(EncodingEventSubscriberTest, MultiplePacketEvents) { ASSERT_EQ(2u, packet_events_.size()); - RtpTimestamp relative_rtp_timestamp = rtp_timestamp_1 - first_rtp_timestamp_; PacketEventList::iterator it = packet_events_.begin(); linked_ptr<AggregatedPacketEvent> event = *it; - EXPECT_EQ(relative_rtp_timestamp, event->relative_rtp_timestamp()); + EXPECT_EQ((rtp_timestamp_1 - first_rtp_timestamp_).lower_32_bits(), + event->relative_rtp_timestamp()); ASSERT_EQ(1, event->base_packet_event_size()); const BasePacketEvent& base_event = event->base_packet_event(0); @@ -590,12 +591,12 @@ TEST_F(EncodingEventSubscriberTest, MultiplePacketEvents) { ASSERT_EQ(1, base_event.event_timestamp_ms_size()); EXPECT_EQ(InMilliseconds(now1), base_event.event_timestamp_ms(0)); - relative_rtp_timestamp = rtp_timestamp_2 - first_rtp_timestamp_; ++it; ASSERT_TRUE(it != packet_events_.end()); event = *it; - EXPECT_EQ(relative_rtp_timestamp, event->relative_rtp_timestamp()); + EXPECT_EQ((rtp_timestamp_2 - first_rtp_timestamp_).lower_32_bits(), + event->relative_rtp_timestamp()); ASSERT_EQ(1, event->base_packet_event_size()); const BasePacketEvent& base_event_2 = event->base_packet_event(0); @@ -607,9 +608,9 @@ TEST_F(EncodingEventSubscriberTest, MultiplePacketEvents) { EXPECT_EQ(InMilliseconds(now2), base_event_2.event_timestamp_ms(0)); } -TEST_F(EncodingEventSubscriberTest, FirstRtpTimestamp) { +TEST_F(EncodingEventSubscriberTest, FirstRtpTimeTicks) { Init(VIDEO_EVENT); - RtpTimestamp rtp_timestamp = 12345; + RtpTimeTicks rtp_timestamp = RtpTimeTicks().Expand(UINT32_C(12345)); base::TimeTicks now(testing_clock_->NowTicks()); scoped_ptr<FrameEvent> capture_begin_event(new FrameEvent()); @@ -624,7 +625,8 @@ TEST_F(EncodingEventSubscriberTest, FirstRtpTimestamp) { capture_end_event->timestamp = now; capture_end_event->type = FRAME_CAPTURE_END; capture_end_event->media_type = VIDEO_EVENT; - capture_end_event->rtp_timestamp = rtp_timestamp + 30; + capture_end_event->rtp_timestamp = + rtp_timestamp + RtpTimeDelta::FromTicks(30); capture_end_event->width = 1280; capture_end_event->height = 720; cast_environment_->logger()->DispatchFrameEvent(std::move(capture_end_event)); @@ -642,7 +644,7 @@ TEST_F(EncodingEventSubscriberTest, FirstRtpTimestamp) { EXPECT_EQ(1280, (*it)->width()); EXPECT_EQ(720, (*it)->height()); - rtp_timestamp = 67890; + rtp_timestamp = rtp_timestamp.Expand(UINT32_C(67890)); capture_begin_event.reset(new FrameEvent()); capture_begin_event->timestamp = now; @@ -657,9 +659,9 @@ TEST_F(EncodingEventSubscriberTest, FirstRtpTimestamp) { EXPECT_EQ(rtp_timestamp, first_rtp_timestamp_); } -TEST_F(EncodingEventSubscriberTest, RelativeRtpTimestampWrapAround) { +TEST_F(EncodingEventSubscriberTest, RelativeRtpTimeTicksWrapAround) { Init(VIDEO_EVENT); - RtpTimestamp rtp_timestamp = 0xffffffff - 20; + RtpTimeTicks rtp_timestamp = RtpTimeTicks() - RtpTimeDelta::FromTicks(20); base::TimeTicks now(testing_clock_->NowTicks()); scoped_ptr<FrameEvent> capture_begin_event(new FrameEvent()); @@ -670,12 +672,13 @@ TEST_F(EncodingEventSubscriberTest, RelativeRtpTimestampWrapAround) { cast_environment_->logger()->DispatchFrameEvent( std::move(capture_begin_event)); - // RtpTimestamp has now wrapped around. + // RtpTimeTicks has now wrapped around. scoped_ptr<FrameEvent> capture_end_event(new FrameEvent()); capture_end_event->timestamp = now; capture_end_event->type = FRAME_CAPTURE_END; capture_end_event->media_type = VIDEO_EVENT; - capture_end_event->rtp_timestamp = rtp_timestamp + 30; + capture_end_event->rtp_timestamp = + rtp_timestamp + RtpTimeDelta::FromTicks(30); capture_end_event->width = 1280; capture_end_event->height = 720; cast_environment_->logger()->DispatchFrameEvent(std::move(capture_end_event)); @@ -695,7 +698,7 @@ TEST_F(EncodingEventSubscriberTest, RelativeRtpTimestampWrapAround) { TEST_F(EncodingEventSubscriberTest, MaxEventsPerProto) { Init(VIDEO_EVENT); - RtpTimestamp rtp_timestamp = 100; + RtpTimeTicks rtp_timestamp = RtpTimeTicks().Expand(UINT32_C(100)); for (int i = 0; i < kMaxEventsPerProto + 1; i++) { scoped_ptr<FrameEvent> ack_event(new FrameEvent()); ack_event->timestamp = testing_clock_->NowTicks(); diff --git a/media/cast/logging/log_deserializer.cc b/media/cast/logging/log_deserializer.cc index 75095ae..3a58106 100644 --- a/media/cast/logging/log_deserializer.cc +++ b/media/cast/logging/log_deserializer.cc @@ -14,7 +14,8 @@ using media::cast::FrameEventMap; using media::cast::PacketEventMap; -using media::cast::RtpTimestamp; +using media::cast::RtpTimeDelta; +using media::cast::RtpTimeTicks; using media::cast::proto::AggregatedFrameEvent; using media::cast::proto::AggregatedPacketEvent; using media::cast::proto::BasePacketEvent; @@ -73,7 +74,7 @@ bool PopulateDeserializedLog(base::BigEndianReader* reader, PacketEventMap packet_event_map; int num_frame_events = log->metadata.num_frame_events(); - RtpTimestamp relative_rtp_timestamp = 0; + RtpTimeTicks relative_rtp_timestamp; uint16_t proto_size = 0; for (int i = 0; i < num_frame_events; i++) { if (!reader->ReadU16(&proto_size)) @@ -88,15 +89,15 @@ bool PopulateDeserializedLog(base::BigEndianReader* reader, // During serialization the RTP timestamp in proto is relative to previous // frame. // Adjust RTP timestamp back to value relative to first RTP timestamp. + relative_rtp_timestamp += + RtpTimeDelta::FromTicks(frame_event->relative_rtp_timestamp()); frame_event->set_relative_rtp_timestamp( - frame_event->relative_rtp_timestamp() + relative_rtp_timestamp); - relative_rtp_timestamp = frame_event->relative_rtp_timestamp(); + relative_rtp_timestamp.lower_32_bits()); - FrameEventMap::iterator it = frame_event_map.find( - frame_event->relative_rtp_timestamp()); + FrameEventMap::iterator it = frame_event_map.find(relative_rtp_timestamp); if (it == frame_event_map.end()) { frame_event_map.insert( - std::make_pair(frame_event->relative_rtp_timestamp(), frame_event)); + std::make_pair(relative_rtp_timestamp, frame_event)); } else { // Events for the same frame might have been split into more than one // proto. Merge them. @@ -107,7 +108,7 @@ bool PopulateDeserializedLog(base::BigEndianReader* reader, log->frame_events.swap(frame_event_map); int num_packet_events = log->metadata.num_packet_events(); - relative_rtp_timestamp = 0; + relative_rtp_timestamp = RtpTimeTicks(); for (int i = 0; i < num_packet_events; i++) { if (!reader->ReadU16(&proto_size)) return false; @@ -118,15 +119,15 @@ bool PopulateDeserializedLog(base::BigEndianReader* reader, if (!reader->Skip(proto_size)) return false; + relative_rtp_timestamp += + RtpTimeDelta::FromTicks(packet_event->relative_rtp_timestamp()); packet_event->set_relative_rtp_timestamp( - packet_event->relative_rtp_timestamp() + relative_rtp_timestamp); - relative_rtp_timestamp = packet_event->relative_rtp_timestamp(); + relative_rtp_timestamp.lower_32_bits()); - PacketEventMap::iterator it = packet_event_map.find( - packet_event->relative_rtp_timestamp()); + PacketEventMap::iterator it = packet_event_map.find(relative_rtp_timestamp); if (it == packet_event_map.end()) { packet_event_map.insert( - std::make_pair(packet_event->relative_rtp_timestamp(), packet_event)); + std::make_pair(relative_rtp_timestamp, packet_event)); } else { // Events for the same frame might have been split into more than one // proto. Merge them. diff --git a/media/cast/logging/log_deserializer.h b/media/cast/logging/log_deserializer.h index 01b6db7..c9d4c72 100644 --- a/media/cast/logging/log_deserializer.h +++ b/media/cast/logging/log_deserializer.h @@ -15,11 +15,11 @@ namespace media { namespace cast { -typedef std::map<RtpTimestamp, - linked_ptr<media::cast::proto::AggregatedFrameEvent> > +typedef std::map<RtpTimeTicks, + linked_ptr<media::cast::proto::AggregatedFrameEvent>> FrameEventMap; -typedef std::map<RtpTimestamp, - linked_ptr<media::cast::proto::AggregatedPacketEvent> > +typedef std::map<RtpTimeTicks, + linked_ptr<media::cast::proto::AggregatedPacketEvent>> PacketEventMap; // Represents deserialized raw event logs for a particular stream. diff --git a/media/cast/logging/log_serializer.cc b/media/cast/logging/log_serializer.cc index 6136518..eec4b2b 100644 --- a/media/cast/logging/log_serializer.cc +++ b/media/cast/logging/log_serializer.cc @@ -56,7 +56,7 @@ bool DoSerializeEvents(const LogMetadata& metadata, if (!writer.Skip(proto_size)) return false; - RtpTimestamp prev_rtp_timestamp = 0; + RtpTimeTicks prev_rtp_timestamp; for (media::cast::FrameEventList::const_iterator it = frame_events.begin(); it != frame_events.end(); ++it) { @@ -65,11 +65,11 @@ bool DoSerializeEvents(const LogMetadata& metadata, // Adjust relative RTP timestamp so that it is relative to previous frame, // rather than relative to first RTP timestamp. // This is done to improve encoding size. - RtpTimestamp old_relative_rtp_timestamp = - frame_event.relative_rtp_timestamp(); + const RtpTimeTicks rtp_timestamp = + prev_rtp_timestamp.Expand(frame_event.relative_rtp_timestamp()); frame_event.set_relative_rtp_timestamp( - old_relative_rtp_timestamp - prev_rtp_timestamp); - prev_rtp_timestamp = old_relative_rtp_timestamp; + (rtp_timestamp - prev_rtp_timestamp).lower_32_bits()); + prev_rtp_timestamp = rtp_timestamp; proto_size = frame_event.ByteSize(); DCHECK(proto_size <= kMaxSerializedProtoBytes); @@ -84,16 +84,17 @@ bool DoSerializeEvents(const LogMetadata& metadata, } // Write packet events. - prev_rtp_timestamp = 0; + prev_rtp_timestamp = RtpTimeTicks(); for (media::cast::PacketEventList::const_iterator it = packet_events.begin(); it != packet_events.end(); ++it) { media::cast::proto::AggregatedPacketEvent packet_event(**it); - RtpTimestamp old_relative_rtp_timestamp = - packet_event.relative_rtp_timestamp(); + + const RtpTimeTicks rtp_timestamp = + prev_rtp_timestamp.Expand(packet_event.relative_rtp_timestamp()); packet_event.set_relative_rtp_timestamp( - old_relative_rtp_timestamp - prev_rtp_timestamp); - prev_rtp_timestamp = old_relative_rtp_timestamp; + (rtp_timestamp - prev_rtp_timestamp).lower_32_bits()); + prev_rtp_timestamp = rtp_timestamp; proto_size = packet_event.ByteSize(); DCHECK(proto_size <= kMaxSerializedProtoBytes); diff --git a/media/cast/logging/logging_defines.cc b/media/cast/logging/logging_defines.cc index e240b2f..c3c872a 100644 --- a/media/cast/logging/logging_defines.cc +++ b/media/cast/logging/logging_defines.cc @@ -33,15 +33,20 @@ const char* CastLoggingToString(CastLoggingEvent event) { } FrameEvent::FrameEvent() - : rtp_timestamp(0u), frame_id(kFrameIdUnknown), width(0), height(0), - size(0u), type(UNKNOWN), media_type(UNKNOWN_EVENT), key_frame(false), - target_bitrate(0), encoder_cpu_utilization(-1.0), + : frame_id(kFrameIdUnknown), + width(0), + height(0), + size(0u), + type(UNKNOWN), + media_type(UNKNOWN_EVENT), + key_frame(false), + target_bitrate(0), + encoder_cpu_utilization(-1.0), idealized_bitrate_utilization(-1.0) {} FrameEvent::~FrameEvent() {} PacketEvent::PacketEvent() - : rtp_timestamp(0), - frame_id(kFrameIdUnknown), + : frame_id(kFrameIdUnknown), max_packet_id(0), packet_id(0), size(0), diff --git a/media/cast/logging/logging_defines.h b/media/cast/logging/logging_defines.h index 9a8d936..4780d84 100644 --- a/media/cast/logging/logging_defines.h +++ b/media/cast/logging/logging_defines.h @@ -13,14 +13,13 @@ #include <vector> #include "base/time/time.h" +#include "media/cast/common/rtp_time.h" namespace media { namespace cast { static const uint32_t kFrameIdUnknown = 0xFFFFFFFF; -typedef uint32_t RtpTimestamp; - enum CastLoggingEvent { UNKNOWN, // Sender side frame events. @@ -55,7 +54,7 @@ struct FrameEvent { FrameEvent(); ~FrameEvent(); - RtpTimestamp rtp_timestamp; + RtpTimeTicks rtp_timestamp; uint32_t frame_id; // Resolution of the frame. Only set for video FRAME_CAPTURE_END events. @@ -95,7 +94,7 @@ struct PacketEvent { PacketEvent(); ~PacketEvent(); - RtpTimestamp rtp_timestamp; + RtpTimeTicks rtp_timestamp; uint32_t frame_id; uint16_t max_packet_id; uint16_t packet_id; diff --git a/media/cast/logging/receiver_time_offset_estimator_impl.cc b/media/cast/logging/receiver_time_offset_estimator_impl.cc index db80fc4..4a84597 100644 --- a/media/cast/logging/receiver_time_offset_estimator_impl.cc +++ b/media/cast/logging/receiver_time_offset_estimator_impl.cc @@ -12,28 +12,38 @@ namespace media { namespace cast { +namespace { + +// Bitwise merging of values to produce an ordered key for entries in the +// BoundCalculator::events_ map. +uint64_t MakeEventKey(RtpTimeTicks rtp, uint16_t packet_id, bool audio) { + return (static_cast<uint64_t>(rtp.lower_32_bits()) << 32) | + (static_cast<uint64_t>(packet_id) << 1) | + (audio ? UINT64_C(1) : UINT64_C(0)); +} + +} // namespace + ReceiverTimeOffsetEstimatorImpl::BoundCalculator::BoundCalculator() : has_bound_(false) {} ReceiverTimeOffsetEstimatorImpl::BoundCalculator::~BoundCalculator() {} void ReceiverTimeOffsetEstimatorImpl::BoundCalculator::SetSent( - uint32_t rtp, - uint32_t packet_id, + RtpTimeTicks rtp, + uint16_t packet_id, bool audio, base::TimeTicks t) { - uint64_t key = (static_cast<uint64_t>(rtp) << 32) | (packet_id << 1) | - static_cast<uint64_t>(audio); + const uint64_t key = MakeEventKey(rtp, packet_id, audio); events_[key].first = t; CheckUpdate(key); } void ReceiverTimeOffsetEstimatorImpl::BoundCalculator::SetReceived( - uint32_t rtp, + RtpTimeTicks rtp, uint16_t packet_id, bool audio, base::TimeTicks t) { - uint64_t key = (static_cast<uint64_t>(rtp) << 32) | (packet_id << 1) | - static_cast<uint64_t>(audio); + const uint64_t key = MakeEventKey(rtp, packet_id, audio); events_[key].second = t; CheckUpdate(key); } diff --git a/media/cast/logging/receiver_time_offset_estimator_impl.h b/media/cast/logging/receiver_time_offset_estimator_impl.h index 71316e1..bb1dd49 100644 --- a/media/cast/logging/receiver_time_offset_estimator_impl.h +++ b/media/cast/logging/receiver_time_offset_estimator_impl.h @@ -69,12 +69,12 @@ class ReceiverTimeOffsetEstimatorImpl : public ReceiverTimeOffsetEstimator { bool has_bound() const { return has_bound_; } base::TimeDelta bound() const { return bound_; } - void SetSent(uint32_t rtp, - uint32_t packet_id, + void SetSent(RtpTimeTicks rtp, + uint16_t packet_id, bool audio, base::TimeTicks t); - void SetReceived(uint32_t rtp, + void SetReceived(RtpTimeTicks rtp, uint16_t packet_id, bool audio, base::TimeTicks t); diff --git a/media/cast/logging/receiver_time_offset_estimator_impl_unittest.cc b/media/cast/logging/receiver_time_offset_estimator_impl_unittest.cc index 73ddd62..02d8b4c 100644 --- a/media/cast/logging/receiver_time_offset_estimator_impl_unittest.cc +++ b/media/cast/logging/receiver_time_offset_estimator_impl_unittest.cc @@ -62,7 +62,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, EstimateOffset) { EXPECT_FALSE(estimator_.GetReceiverOffsetBounds(&lower_bound, &upper_bound)); - RtpTimestamp rtp_timestamp = 0; + const RtpTimeTicks rtp_timestamp; uint32_t frame_id = 0; AdvanceClocks(base::TimeDelta::FromMilliseconds(20)); @@ -145,7 +145,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, EventCArrivesBeforeEventB) { EXPECT_FALSE(estimator_.GetReceiverOffsetBounds(&lower_bound, &upper_bound)); - RtpTimestamp rtp_timestamp = 0; + const RtpTimeTicks rtp_timestamp; uint32_t frame_id = 0; AdvanceClocks(base::TimeDelta::FromMilliseconds(20)); @@ -227,11 +227,13 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, MultipleIterations) { base::TimeDelta lower_bound; base::TimeDelta upper_bound; - RtpTimestamp rtp_timestamp_a = 0; + const RtpTimeTicks rtp_timestamp_a; int frame_id_a = 0; - RtpTimestamp rtp_timestamp_b = 90; + const RtpTimeTicks rtp_timestamp_b = + rtp_timestamp_a + RtpTimeDelta::FromTicks(90); int frame_id_b = 1; - RtpTimestamp rtp_timestamp_c = 180; + const RtpTimeTicks rtp_timestamp_c = + rtp_timestamp_b + RtpTimeDelta::FromTicks(90); int frame_id_c = 2; // Frame 1 times: [20, 30+100, 60] diff --git a/media/cast/logging/simple_event_subscriber_unittest.cc b/media/cast/logging/simple_event_subscriber_unittest.cc index f1f5f14..d0b91cd 100644 --- a/media/cast/logging/simple_event_subscriber_unittest.cc +++ b/media/cast/logging/simple_event_subscriber_unittest.cc @@ -47,7 +47,7 @@ TEST_F(SimpleEventSubscriberTest, GetAndResetEvents) { encode_event->timestamp = testing_clock_->NowTicks(); encode_event->type = FRAME_ENCODED; encode_event->media_type = AUDIO_EVENT; - encode_event->rtp_timestamp = 100u; + encode_event->rtp_timestamp = RtpTimeTicks().Expand(UINT32_C(100)); encode_event->frame_id = 0u; encode_event->size = 1234; encode_event->key_frame = true; @@ -60,7 +60,7 @@ TEST_F(SimpleEventSubscriberTest, GetAndResetEvents) { playout_event->timestamp = testing_clock_->NowTicks(); playout_event->type = FRAME_PLAYOUT; playout_event->media_type = AUDIO_EVENT; - playout_event->rtp_timestamp = 100u; + playout_event->rtp_timestamp = RtpTimeTicks().Expand(UINT32_C(100)); playout_event->frame_id = 0u; playout_event->delay_delta = base::TimeDelta::FromMilliseconds(100); cast_environment_->logger()->DispatchFrameEvent(std::move(playout_event)); @@ -69,7 +69,7 @@ TEST_F(SimpleEventSubscriberTest, GetAndResetEvents) { decode_event->timestamp = testing_clock_->NowTicks(); decode_event->type = FRAME_DECODED; decode_event->media_type = AUDIO_EVENT; - decode_event->rtp_timestamp = 200u; + decode_event->rtp_timestamp = RtpTimeTicks().Expand(UINT32_C(200)); decode_event->frame_id = 0u; cast_environment_->logger()->DispatchFrameEvent(std::move(decode_event)); @@ -78,7 +78,7 @@ TEST_F(SimpleEventSubscriberTest, GetAndResetEvents) { receive_event->timestamp = testing_clock_->NowTicks(); receive_event->type = PACKET_RECEIVED; receive_event->media_type = AUDIO_EVENT; - receive_event->rtp_timestamp = 200u; + receive_event->rtp_timestamp = RtpTimeTicks().Expand(UINT32_C(200)); receive_event->frame_id = 0u; receive_event->packet_id = 1u; receive_event->max_packet_id = 5u; @@ -89,7 +89,7 @@ TEST_F(SimpleEventSubscriberTest, GetAndResetEvents) { receive_event->timestamp = testing_clock_->NowTicks(); receive_event->type = PACKET_RECEIVED; receive_event->media_type = VIDEO_EVENT; - receive_event->rtp_timestamp = 200u; + receive_event->rtp_timestamp = RtpTimeTicks().Expand(UINT32_C(200)); receive_event->frame_id = 0u; receive_event->packet_id = 1u; receive_event->max_packet_id = 10u; diff --git a/media/cast/logging/stats_event_subscriber.cc b/media/cast/logging/stats_event_subscriber.cc index 61cd4ae..0e00729 100644 --- a/media/cast/logging/stats_event_subscriber.cc +++ b/media/cast/logging/stats_event_subscriber.cc @@ -484,7 +484,7 @@ bool StatsEventSubscriber::GetReceiverOffset(base::TimeDelta* offset) { return true; } -void StatsEventSubscriber::MaybeInsertFrameInfo(RtpTimestamp rtp_timestamp, +void StatsEventSubscriber::MaybeInsertFrameInfo(RtpTimeTicks rtp_timestamp, const FrameInfo& frame_info) { // No need to insert if |rtp_timestamp| is the smaller than every key in the // map as it is just going to get erased anyway. @@ -596,7 +596,7 @@ void StatsEventSubscriber::UpdateLastResponseTime( void StatsEventSubscriber::ErasePacketSentTime( const PacketEvent& packet_event) { - std::pair<RtpTimestamp, uint16_t> key( + std::pair<RtpTimeTicks, uint16_t> key( std::make_pair(packet_event.rtp_timestamp, packet_event.packet_id)); packet_sent_times_.erase(key); } @@ -622,7 +622,7 @@ void StatsEventSubscriber::RecordPacketRelatedLatencies( if (!GetReceiverOffset(&receiver_offset)) return; - std::pair<RtpTimestamp, uint16_t> key( + std::pair<RtpTimeTicks, uint16_t> key( std::make_pair(packet_event.rtp_timestamp, packet_event.packet_id)); PacketEventTimeMap::iterator it = packet_sent_times_.find(key); if (it == packet_sent_times_.end()) { diff --git a/media/cast/logging/stats_event_subscriber.h b/media/cast/logging/stats_event_subscriber.h index d1d97be..280519f 100644 --- a/media/cast/logging/stats_event_subscriber.h +++ b/media/cast/logging/stats_event_subscriber.h @@ -186,8 +186,8 @@ class StatsEventSubscriber : public RawEventSubscriber { typedef std::map<CastStat, double> StatsMap; typedef std::map<CastStat, linked_ptr<SimpleHistogram> > HistogramMap; - typedef std::map<RtpTimestamp, FrameInfo> FrameInfoMap; - typedef std::map<std::pair<RtpTimestamp, uint16_t>, + typedef std::map<RtpTimeTicks, FrameInfo> FrameInfoMap; + typedef std::map<std::pair<RtpTimeTicks, uint16_t>, std::pair<base::TimeTicks, CastLoggingEvent>> PacketEventTimeMap; typedef std::map<CastLoggingEvent, FrameLogStats> FrameStatsMap; @@ -206,7 +206,7 @@ class StatsEventSubscriber : public RawEventSubscriber { void UpdateFirstLastEventTime(base::TimeTicks timestamp, bool is_receiver_event); bool GetReceiverOffset(base::TimeDelta* offset); - void MaybeInsertFrameInfo(RtpTimestamp rtp_timestamp, + void MaybeInsertFrameInfo(RtpTimeTicks rtp_timestamp, const FrameInfo& frame_info); void RecordFrameCaptureTime(const FrameEvent& frame_event); void RecordCaptureLatency(const FrameEvent& frame_event); diff --git a/media/cast/logging/stats_event_subscriber_unittest.cc b/media/cast/logging/stats_event_subscriber_unittest.cc index 7acfddd..6c210e6 100644 --- a/media/cast/logging/stats_event_subscriber_unittest.cc +++ b/media/cast/logging/stats_event_subscriber_unittest.cc @@ -72,7 +72,7 @@ class StatsEventSubscriberTest : public ::testing::Test { TEST_F(StatsEventSubscriberTest, CaptureEncode) { Init(VIDEO_EVENT); - uint32_t rtp_timestamp = 0; + RtpTimeTicks rtp_timestamp; uint32_t frame_id = 0; int extra_frames = 50; // Only the first |extra_frames| frames logged will be taken into account @@ -117,7 +117,7 @@ TEST_F(StatsEventSubscriberTest, CaptureEncode) { dropped_frames++; } AdvanceClocks(base::TimeDelta::FromMicroseconds(34567)); - rtp_timestamp += 90; + rtp_timestamp += RtpTimeDelta::FromTicks(90); frame_id++; } @@ -154,7 +154,7 @@ TEST_F(StatsEventSubscriberTest, CaptureEncode) { TEST_F(StatsEventSubscriberTest, Encode) { Init(VIDEO_EVENT); - uint32_t rtp_timestamp = 0; + RtpTimeTicks rtp_timestamp; uint32_t frame_id = 0; int num_frames = 10; base::TimeTicks start_time = sender_clock_->NowTicks(); @@ -180,7 +180,7 @@ TEST_F(StatsEventSubscriberTest, Encode) { last_event_time = sender_clock_->NowTicks(); AdvanceClocks(base::TimeDelta::FromMicroseconds(35678)); - rtp_timestamp += 90; + rtp_timestamp += RtpTimeDelta::FromTicks(90); frame_id++; } @@ -222,7 +222,7 @@ TEST_F(StatsEventSubscriberTest, Encode) { TEST_F(StatsEventSubscriberTest, Decode) { Init(VIDEO_EVENT); - uint32_t rtp_timestamp = 0; + RtpTimeTicks rtp_timestamp; uint32_t frame_id = 0; int num_frames = 10; base::TimeTicks start_time = sender_clock_->NowTicks(); @@ -236,7 +236,7 @@ TEST_F(StatsEventSubscriberTest, Decode) { cast_environment_->logger()->DispatchFrameEvent(std::move(decode_event)); AdvanceClocks(base::TimeDelta::FromMicroseconds(36789)); - rtp_timestamp += 90; + rtp_timestamp += RtpTimeDelta::FromTicks(90); frame_id++; } @@ -258,7 +258,7 @@ TEST_F(StatsEventSubscriberTest, Decode) { TEST_F(StatsEventSubscriberTest, PlayoutDelay) { Init(VIDEO_EVENT); - uint32_t rtp_timestamp = 0; + RtpTimeTicks rtp_timestamp; uint32_t frame_id = 0; int num_frames = 10; int late_frames = 0; @@ -276,7 +276,7 @@ TEST_F(StatsEventSubscriberTest, PlayoutDelay) { cast_environment_->logger()->DispatchFrameEvent(std::move(playout_event)); AdvanceClocks(base::TimeDelta::FromMicroseconds(37890)); - rtp_timestamp += 90; + rtp_timestamp += RtpTimeDelta::FromTicks(90); frame_id++; } @@ -293,7 +293,7 @@ TEST_F(StatsEventSubscriberTest, PlayoutDelay) { TEST_F(StatsEventSubscriberTest, E2ELatency) { Init(VIDEO_EVENT); - uint32_t rtp_timestamp = 0; + RtpTimeTicks rtp_timestamp; uint32_t frame_id = 0; int num_frames = 10; base::TimeDelta total_latency; @@ -323,7 +323,7 @@ TEST_F(StatsEventSubscriberTest, E2ELatency) { playout_event->delay_delta = delay; cast_environment_->logger()->DispatchFrameEvent(std::move(playout_event)); - rtp_timestamp += 90; + rtp_timestamp += RtpTimeDelta::FromTicks(90); frame_id++; } @@ -341,7 +341,7 @@ TEST_F(StatsEventSubscriberTest, E2ELatency) { TEST_F(StatsEventSubscriberTest, Packets) { Init(VIDEO_EVENT); - uint32_t rtp_timestamp = 0; + RtpTimeTicks rtp_timestamp; int num_packets = 10; int num_latency_recorded_packets = 0; base::TimeTicks start_time = sender_clock_->NowTicks(); @@ -568,14 +568,14 @@ TEST_F(StatsEventSubscriberTest, Histograms) { Init(VIDEO_EVENT); AdvanceClocks(base::TimeDelta::FromMilliseconds(123)); - uint32_t rtp_timestamp = 123; + RtpTimeTicks rtp_timestamp = RtpTimeTicks().Expand(UINT32_C(123)); uint32_t frame_id = 0; // 10 Frames with capture latency in the bucket of "10-14"ms. // 10 Frames with encode time in the bucket of "15-19"ms. for (int i = 0; i < 10; ++i) { ++frame_id; - ++rtp_timestamp; + rtp_timestamp += RtpTimeDelta::FromTicks(1); scoped_ptr<FrameEvent> capture_begin_event(new FrameEvent()); capture_begin_event->timestamp = sender_clock_->NowTicks(); |