diff options
author | imcheng@chromium.org <imcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-10 01:49:57 +0000 |
---|---|---|
committer | imcheng@chromium.org <imcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-10 01:49:57 +0000 |
commit | a7a1c83a1fab0b235777ae65a5cb864e8fd9d9f0 (patch) | |
tree | b816162ddd83aa73cd4e7bf40b1d6c26a1854c5b /media/cast/logging | |
parent | 2238f365d9548da8c789f3fde56057bc15311a35 (diff) | |
download | chromium_src-a7a1c83a1fab0b235777ae65a5cb864e8fd9d9f0.zip chromium_src-a7a1c83a1fab0b235777ae65a5cb864e8fd9d9f0.tar.gz chromium_src-a7a1c83a1fab0b235777ae65a5cb864e8fd9d9f0.tar.bz2 |
Cast: Deduplicate event types in cast library.
- Remove k{Audio,Video}XXX event types and add in kXXX event types to
be shared between audio and video.
- Changed RTCP event mapping to accept both k{A,V}XXX and kXXX event
type encodings from the receiver. Old encodings get mapped to the
unified types on sender side.
- Changed reciever reference implementation to always send new unified
event types.
- Changed LoggingImpl::Insert{Frame,Packet}Event calls to take
additional EventMediaType argument.
- Added a param in RTCP to indicate whether receiver events
from incoming ssrc are audio or video events.
- Remove generic event types.
- Remove other unused events
-- kVideoFrameSentToEncoder
-- k{AV}PacketSentToPacer
-- kDuplicate{AV}PacketReceived
BUG=365829
Review URL: https://codereview.chromium.org/270493003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269473 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/cast/logging')
21 files changed, 374 insertions, 395 deletions
diff --git a/media/cast/logging/encoding_event_subscriber.cc b/media/cast/logging/encoding_event_subscriber.cc index 2ccf731..e2eb37a 100644 --- a/media/cast/logging/encoding_event_subscriber.cc +++ b/media/cast/logging/encoding_event_subscriber.cc @@ -62,7 +62,7 @@ void EncodingEventSubscriber::OnReceiveFrameEvent( const FrameEvent& frame_event) { DCHECK(thread_checker_.CalledOnValidThread()); - if (!ShouldProcessEvent(frame_event.type)) + if (event_media_type_ != frame_event.media_type) return; RtpTimestamp relative_rtp_timestamp = @@ -92,14 +92,14 @@ void EncodingEventSubscriber::OnReceiveFrameEvent( event_proto->add_event_timestamp_ms( (frame_event.timestamp - base::TimeTicks()).InMilliseconds()); - if (frame_event.type == kAudioFrameEncoded) { + if (frame_event.type == FRAME_ENCODED) { event_proto->set_encoded_frame_size(frame_event.size); - } else if (frame_event.type == kVideoFrameEncoded) { - event_proto->set_encoded_frame_size(frame_event.size); - event_proto->set_key_frame(frame_event.key_frame); - event_proto->set_target_bitrate(frame_event.target_bitrate); - } else if (frame_event.type == kAudioPlayoutDelay || - frame_event.type == kVideoRenderDelay) { + if (frame_event.media_type == VIDEO_EVENT) { + event_proto->set_encoded_frame_size(frame_event.size); + event_proto->set_key_frame(frame_event.key_frame); + event_proto->set_target_bitrate(frame_event.target_bitrate); + } + } else if (frame_event.type == FRAME_PLAYOUT) { event_proto->set_delay_millis(frame_event.delay_delta.InMilliseconds()); } @@ -114,7 +114,7 @@ void EncodingEventSubscriber::OnReceivePacketEvent( const PacketEvent& packet_event) { DCHECK(thread_checker_.CalledOnValidThread()); - if (!ShouldProcessEvent(packet_event.type)) + if (event_media_type_ != packet_event.media_type) return; RtpTimestamp relative_rtp_timestamp = GetRelativeRtpTimestamp(packet_event.rtp_timestamp); @@ -208,10 +208,6 @@ void EncodingEventSubscriber::GetEventsAndReset(LogMetadata* metadata, Reset(); } -bool EncodingEventSubscriber::ShouldProcessEvent(CastLoggingEvent event) { - return GetEventMediaType(event) == event_media_type_; -} - void EncodingEventSubscriber::TransferFrameEvents(size_t max_num_entries) { DCHECK(frame_event_map_.size() >= max_num_entries); diff --git a/media/cast/logging/encoding_event_subscriber.h b/media/cast/logging/encoding_event_subscriber.h index c507499..ca2cccb 100644 --- a/media/cast/logging/encoding_event_subscriber.h +++ b/media/cast/logging/encoding_event_subscriber.h @@ -72,8 +72,6 @@ class EncodingEventSubscriber : public RawEventSubscriber { linked_ptr<media::cast::proto::AggregatedPacketEvent> > PacketEventMap; - bool ShouldProcessEvent(CastLoggingEvent event); - // Transfer up to |max_num_entries| smallest entries from |frame_event_map_| // to |frame_event_storage_|. This helps keep size of |frame_event_map_| small // and lookup speed fast. diff --git a/media/cast/logging/encoding_event_subscriber_unittest.cc b/media/cast/logging/encoding_event_subscriber_unittest.cc index 264ae93..3d77a62 100644 --- a/media/cast/logging/encoding_event_subscriber_unittest.cc +++ b/media/cast/logging/encoding_event_subscriber_unittest.cc @@ -78,11 +78,13 @@ TEST_F(EncodingEventSubscriberTest, FrameEventTruncating) { // Entry with RTP timestamp 0 should get dropped. for (int i = 0; i < 11; i++) { cast_environment_->Logging()->InsertFrameEvent(now, - kVideoFrameCaptureBegin, + FRAME_CAPTURE_BEGIN, + VIDEO_EVENT, i * 100, /*frame_id*/ 0); cast_environment_->Logging()->InsertFrameEvent(now, - kVideoFrameDecoded, + FRAME_DECODED, + VIDEO_EVENT, i * 100, /*frame_id*/ 0); } @@ -102,7 +104,8 @@ TEST_F(EncodingEventSubscriberTest, PacketEventTruncating) { // Entry with RTP timestamp 0 should get dropped. for (int i = 0; i < 11; i++) { cast_environment_->Logging()->InsertPacketEvent(now, - kAudioPacketReceived, + PACKET_RECEIVED, + AUDIO_EVENT, /*rtp_timestamp*/ i * 100, /*frame_id*/ 0, /*packet_id*/ i, @@ -123,13 +126,15 @@ TEST_F(EncodingEventSubscriberTest, EventFiltering) { base::TimeTicks now(testing_clock_->NowTicks()); RtpTimestamp rtp_timestamp = 100; cast_environment_->Logging()->InsertFrameEvent(now, - kVideoFrameDecoded, + FRAME_DECODED, + VIDEO_EVENT, rtp_timestamp, /*frame_id*/ 0); // This is an AUDIO_EVENT and shouldn't be processed by the subscriber. cast_environment_->Logging()->InsertFrameEvent(now, - kAudioFrameDecoded, + FRAME_DECODED, + AUDIO_EVENT, rtp_timestamp, /*frame_id*/ 0); @@ -141,7 +146,7 @@ TEST_F(EncodingEventSubscriberTest, EventFiltering) { linked_ptr<AggregatedFrameEvent> frame_event = *it; ASSERT_EQ(1, frame_event->event_type_size()); - EXPECT_EQ(media::cast::proto::VIDEO_FRAME_DECODED, + EXPECT_EQ(media::cast::proto::FRAME_DECODED, frame_event->event_type(0)); GetEventsAndReset(); @@ -153,7 +158,8 @@ TEST_F(EncodingEventSubscriberTest, FrameEvent) { Init(VIDEO_EVENT); base::TimeTicks now(testing_clock_->NowTicks()); RtpTimestamp rtp_timestamp = 100; - cast_environment_->Logging()->InsertFrameEvent(now, kVideoFrameDecoded, + cast_environment_->Logging()->InsertFrameEvent(now, FRAME_DECODED, + VIDEO_EVENT, rtp_timestamp, /*frame_id*/ 0); @@ -169,7 +175,7 @@ TEST_F(EncodingEventSubscriberTest, FrameEvent) { EXPECT_EQ(relative_rtp_timestamp, event->relative_rtp_timestamp()); ASSERT_EQ(1, event->event_type_size()); - EXPECT_EQ(media::cast::proto::VIDEO_FRAME_DECODED, event->event_type(0)); + EXPECT_EQ(media::cast::proto::FRAME_DECODED, event->event_type(0)); ASSERT_EQ(1, event->event_timestamp_ms_size()); EXPECT_EQ(InMilliseconds(now), event->event_timestamp_ms(0)); @@ -186,7 +192,7 @@ TEST_F(EncodingEventSubscriberTest, FrameEventDelay) { RtpTimestamp rtp_timestamp = 100; int delay_ms = 100; cast_environment_->Logging()->InsertFrameEventWithDelay( - now, kAudioPlayoutDelay, rtp_timestamp, + now, FRAME_PLAYOUT, AUDIO_EVENT, rtp_timestamp, /*frame_id*/ 0, base::TimeDelta::FromMilliseconds(delay_ms)); GetEventsAndReset(); @@ -201,7 +207,7 @@ TEST_F(EncodingEventSubscriberTest, FrameEventDelay) { EXPECT_EQ(relative_rtp_timestamp, event->relative_rtp_timestamp()); ASSERT_EQ(1, event->event_type_size()); - EXPECT_EQ(media::cast::proto::AUDIO_PLAYOUT_DELAY, event->event_type(0)); + EXPECT_EQ(media::cast::proto::FRAME_PLAYOUT, event->event_type(0)); ASSERT_EQ(1, event->event_timestamp_ms_size()); EXPECT_EQ(InMilliseconds(now), event->event_timestamp_ms(0)); @@ -218,7 +224,7 @@ TEST_F(EncodingEventSubscriberTest, FrameEventSize) { bool key_frame = true; int target_bitrate = 1024; cast_environment_->Logging()->InsertEncodedFrameEvent( - now, kVideoFrameEncoded, rtp_timestamp, + now, FRAME_ENCODED, VIDEO_EVENT, rtp_timestamp, /*frame_id*/ 0, size, key_frame, target_bitrate); GetEventsAndReset(); @@ -233,7 +239,7 @@ TEST_F(EncodingEventSubscriberTest, FrameEventSize) { EXPECT_EQ(relative_rtp_timestamp, event->relative_rtp_timestamp()); ASSERT_EQ(1, event->event_type_size()); - EXPECT_EQ(media::cast::proto::VIDEO_FRAME_ENCODED, event->event_type(0)); + EXPECT_EQ(media::cast::proto::FRAME_ENCODED, event->event_type(0)); ASSERT_EQ(1, event->event_timestamp_ms_size()); EXPECT_EQ(InMilliseconds(now), event->event_timestamp_ms(0)); @@ -250,20 +256,20 @@ TEST_F(EncodingEventSubscriberTest, MultipleFrameEvents) { RtpTimestamp rtp_timestamp2 = 200; base::TimeTicks now1(testing_clock_->NowTicks()); cast_environment_->Logging()->InsertFrameEventWithDelay( - now1, kAudioPlayoutDelay, rtp_timestamp1, + now1, FRAME_PLAYOUT, AUDIO_EVENT, rtp_timestamp1, /*frame_id*/ 0, /*delay*/ base::TimeDelta::FromMilliseconds(100)); testing_clock_->Advance(base::TimeDelta::FromMilliseconds(20)); base::TimeTicks now2(testing_clock_->NowTicks()); cast_environment_->Logging()->InsertEncodedFrameEvent( - now2, kAudioFrameEncoded, rtp_timestamp2, + now2, FRAME_ENCODED, AUDIO_EVENT, rtp_timestamp2, /*frame_id*/ 0, /*size*/ 123, /* key_frame - unused */ false, /*target_bitrate - unused*/ 0); testing_clock_->Advance(base::TimeDelta::FromMilliseconds(20)); base::TimeTicks now3(testing_clock_->NowTicks()); cast_environment_->Logging()->InsertFrameEvent( - now3, kAudioFrameDecoded, rtp_timestamp1, /*frame_id*/ 0); + now3, FRAME_DECODED, AUDIO_EVENT, rtp_timestamp1, /*frame_id*/ 0); GetEventsAndReset(); @@ -277,8 +283,8 @@ TEST_F(EncodingEventSubscriberTest, MultipleFrameEvents) { EXPECT_EQ(relative_rtp_timestamp, event->relative_rtp_timestamp()); ASSERT_EQ(2, event->event_type_size()); - EXPECT_EQ(media::cast::proto::AUDIO_PLAYOUT_DELAY, event->event_type(0)); - EXPECT_EQ(media::cast::proto::AUDIO_FRAME_DECODED, event->event_type(1)); + EXPECT_EQ(media::cast::proto::FRAME_PLAYOUT, event->event_type(0)); + EXPECT_EQ(media::cast::proto::FRAME_DECODED, event->event_type(1)); ASSERT_EQ(2, event->event_timestamp_ms_size()); EXPECT_EQ(InMilliseconds(now1), event->event_timestamp_ms(0)); @@ -294,7 +300,7 @@ TEST_F(EncodingEventSubscriberTest, MultipleFrameEvents) { EXPECT_EQ(relative_rtp_timestamp, event->relative_rtp_timestamp()); ASSERT_EQ(1, event->event_type_size()); - EXPECT_EQ(media::cast::proto::AUDIO_FRAME_ENCODED, event->event_type(0)); + EXPECT_EQ(media::cast::proto::FRAME_ENCODED, event->event_type(0)); ASSERT_EQ(1, event->event_timestamp_ms_size()); EXPECT_EQ(InMilliseconds(now2), event->event_timestamp_ms(0)); @@ -309,7 +315,8 @@ TEST_F(EncodingEventSubscriberTest, PacketEvent) { int packet_id = 2; int size = 100; cast_environment_->Logging()->InsertPacketEvent( - now, kAudioPacketReceived, rtp_timestamp, /*frame_id*/ 0, packet_id, + now, PACKET_RECEIVED, AUDIO_EVENT, + rtp_timestamp, /*frame_id*/ 0, packet_id, /*max_packet_id*/ 10, size); GetEventsAndReset(); @@ -327,7 +334,7 @@ TEST_F(EncodingEventSubscriberTest, PacketEvent) { const BasePacketEvent& base_event = event->base_packet_event(0); EXPECT_EQ(packet_id, base_event.packet_id()); ASSERT_EQ(1, base_event.event_type_size()); - EXPECT_EQ(media::cast::proto::AUDIO_PACKET_RECEIVED, + EXPECT_EQ(media::cast::proto::PACKET_RECEIVED, base_event.event_type(0)); ASSERT_EQ(1, base_event.event_timestamp_ms_size()); EXPECT_EQ(InMilliseconds(now), base_event.event_timestamp_ms(0)); @@ -344,7 +351,8 @@ TEST_F(EncodingEventSubscriberTest, MultiplePacketEventsForPacket) { int packet_id = 2; int size = 100; cast_environment_->Logging()->InsertPacketEvent(now1, - kVideoPacketSentToNetwork, + PACKET_SENT_TO_NETWORK, + VIDEO_EVENT, rtp_timestamp, /*frame_id*/ 0, packet_id, @@ -354,7 +362,8 @@ TEST_F(EncodingEventSubscriberTest, MultiplePacketEventsForPacket) { testing_clock_->Advance(base::TimeDelta::FromMilliseconds(20)); base::TimeTicks now2(testing_clock_->NowTicks()); cast_environment_->Logging()->InsertPacketEvent(now2, - kVideoPacketRetransmitted, + PACKET_RETRANSMITTED, + VIDEO_EVENT, rtp_timestamp, /*frame_id*/ 0, packet_id, @@ -376,9 +385,9 @@ TEST_F(EncodingEventSubscriberTest, MultiplePacketEventsForPacket) { const BasePacketEvent& base_event = event->base_packet_event(0); EXPECT_EQ(packet_id, base_event.packet_id()); ASSERT_EQ(2, base_event.event_type_size()); - EXPECT_EQ(media::cast::proto::VIDEO_PACKET_SENT_TO_NETWORK, + EXPECT_EQ(media::cast::proto::PACKET_SENT_TO_NETWORK, base_event.event_type(0)); - EXPECT_EQ(media::cast::proto::VIDEO_PACKET_RETRANSMITTED, + EXPECT_EQ(media::cast::proto::PACKET_RETRANSMITTED, base_event.event_type(1)); ASSERT_EQ(2, base_event.event_timestamp_ms_size()); EXPECT_EQ(InMilliseconds(now1), base_event.event_timestamp_ms(0)); @@ -393,7 +402,8 @@ TEST_F(EncodingEventSubscriberTest, MultiplePacketEventsForFrame) { int packet_id_2 = 3; int size = 100; cast_environment_->Logging()->InsertPacketEvent(now1, - kVideoPacketSentToNetwork, + PACKET_SENT_TO_NETWORK, + VIDEO_EVENT, rtp_timestamp, /*frame_id*/ 0, packet_id_1, @@ -403,7 +413,8 @@ TEST_F(EncodingEventSubscriberTest, MultiplePacketEventsForFrame) { testing_clock_->Advance(base::TimeDelta::FromMilliseconds(20)); base::TimeTicks now2(testing_clock_->NowTicks()); cast_environment_->Logging()->InsertPacketEvent(now2, - kVideoPacketRetransmitted, + PACKET_RETRANSMITTED, + VIDEO_EVENT, rtp_timestamp, /*frame_id*/ 0, packet_id_2, @@ -425,7 +436,7 @@ TEST_F(EncodingEventSubscriberTest, MultiplePacketEventsForFrame) { const BasePacketEvent& base_event = event->base_packet_event(0); EXPECT_EQ(packet_id_1, base_event.packet_id()); ASSERT_EQ(1, base_event.event_type_size()); - EXPECT_EQ(media::cast::proto::VIDEO_PACKET_SENT_TO_NETWORK, + EXPECT_EQ(media::cast::proto::PACKET_SENT_TO_NETWORK, base_event.event_type(0)); ASSERT_EQ(1, base_event.event_timestamp_ms_size()); EXPECT_EQ(InMilliseconds(now1), base_event.event_timestamp_ms(0)); @@ -433,7 +444,7 @@ TEST_F(EncodingEventSubscriberTest, MultiplePacketEventsForFrame) { const BasePacketEvent& base_event_2 = event->base_packet_event(1); EXPECT_EQ(packet_id_2, base_event_2.packet_id()); ASSERT_EQ(1, base_event_2.event_type_size()); - EXPECT_EQ(media::cast::proto::VIDEO_PACKET_RETRANSMITTED, + EXPECT_EQ(media::cast::proto::PACKET_RETRANSMITTED, base_event_2.event_type(0)); ASSERT_EQ(1, base_event_2.event_timestamp_ms_size()); EXPECT_EQ(InMilliseconds(now2), base_event_2.event_timestamp_ms(0)); @@ -448,7 +459,8 @@ TEST_F(EncodingEventSubscriberTest, MultiplePacketEvents) { int packet_id_2 = 3; int size = 100; cast_environment_->Logging()->InsertPacketEvent(now1, - kVideoPacketSentToNetwork, + PACKET_SENT_TO_NETWORK, + VIDEO_EVENT, rtp_timestamp_1, /*frame_id*/ 0, packet_id_1, @@ -458,7 +470,8 @@ TEST_F(EncodingEventSubscriberTest, MultiplePacketEvents) { testing_clock_->Advance(base::TimeDelta::FromMilliseconds(20)); base::TimeTicks now2(testing_clock_->NowTicks()); cast_environment_->Logging()->InsertPacketEvent(now2, - kVideoPacketRetransmitted, + PACKET_RETRANSMITTED, + VIDEO_EVENT, rtp_timestamp_2, /*frame_id*/ 0, packet_id_2, @@ -480,7 +493,7 @@ TEST_F(EncodingEventSubscriberTest, MultiplePacketEvents) { const BasePacketEvent& base_event = event->base_packet_event(0); EXPECT_EQ(packet_id_1, base_event.packet_id()); ASSERT_EQ(1, base_event.event_type_size()); - EXPECT_EQ(media::cast::proto::VIDEO_PACKET_SENT_TO_NETWORK, + EXPECT_EQ(media::cast::proto::PACKET_SENT_TO_NETWORK, base_event.event_type(0)); ASSERT_EQ(1, base_event.event_timestamp_ms_size()); EXPECT_EQ(InMilliseconds(now1), base_event.event_timestamp_ms(0)); @@ -496,7 +509,7 @@ TEST_F(EncodingEventSubscriberTest, MultiplePacketEvents) { const BasePacketEvent& base_event_2 = event->base_packet_event(0); EXPECT_EQ(packet_id_2, base_event_2.packet_id()); ASSERT_EQ(1, base_event_2.event_type_size()); - EXPECT_EQ(media::cast::proto::VIDEO_PACKET_RETRANSMITTED, + EXPECT_EQ(media::cast::proto::PACKET_RETRANSMITTED, base_event_2.event_type(0)); ASSERT_EQ(1, base_event_2.event_timestamp_ms_size()); EXPECT_EQ(InMilliseconds(now2), base_event_2.event_timestamp_ms(0)); @@ -508,12 +521,14 @@ TEST_F(EncodingEventSubscriberTest, FirstRtpTimestamp) { base::TimeTicks now(testing_clock_->NowTicks()); cast_environment_->Logging()->InsertFrameEvent(now, - kVideoFrameCaptureBegin, + FRAME_CAPTURE_BEGIN, + VIDEO_EVENT, rtp_timestamp, /*frame_id*/ 0); cast_environment_->Logging()->InsertFrameEvent(now, - kVideoFrameCaptureEnd, + FRAME_CAPTURE_END, + VIDEO_EVENT, rtp_timestamp + 30, /*frame_id*/ 1); @@ -531,7 +546,8 @@ TEST_F(EncodingEventSubscriberTest, FirstRtpTimestamp) { rtp_timestamp = 67890; cast_environment_->Logging()->InsertFrameEvent(now, - kVideoFrameCaptureBegin, + FRAME_CAPTURE_BEGIN, + VIDEO_EVENT, rtp_timestamp, /*frame_id*/ 0); GetEventsAndReset(); @@ -545,13 +561,15 @@ TEST_F(EncodingEventSubscriberTest, RelativeRtpTimestampWrapAround) { base::TimeTicks now(testing_clock_->NowTicks()); cast_environment_->Logging()->InsertFrameEvent(now, - kVideoFrameCaptureBegin, + FRAME_CAPTURE_BEGIN, + VIDEO_EVENT, rtp_timestamp, /*frame_id*/ 0); // RtpTimestamp has now wrapped around. cast_environment_->Logging()->InsertFrameEvent(now, - kVideoFrameCaptureEnd, + FRAME_CAPTURE_END, + VIDEO_EVENT, rtp_timestamp + 30, /*frame_id*/ 1); @@ -571,7 +589,8 @@ TEST_F(EncodingEventSubscriberTest, MaxEventsPerProto) { RtpTimestamp rtp_timestamp = 100; for (int i = 0; i < kMaxEventsPerProto + 1; i++) { cast_environment_->Logging()->InsertFrameEvent(testing_clock_->NowTicks(), - kVideoAckReceived, + FRAME_ACK_RECEIVED, + VIDEO_EVENT, rtp_timestamp, /*frame_id*/ 0); testing_clock_->Advance(base::TimeDelta::FromMilliseconds(30)); @@ -590,7 +609,8 @@ TEST_F(EncodingEventSubscriberTest, MaxEventsPerProto) { for (int i = 0; i < kMaxPacketsPerFrame + 1; i++) { cast_environment_->Logging()->InsertPacketEvent( testing_clock_->NowTicks(), - kVideoPacketRetransmitted, + PACKET_SENT_TO_NETWORK, + VIDEO_EVENT, rtp_timestamp, /*frame_id*/ 0, i, @@ -618,7 +638,8 @@ TEST_F(EncodingEventSubscriberTest, MaxEventsPerProto) { for (int j = 0; j < kMaxEventsPerProto + 1; j++) { cast_environment_->Logging()->InsertPacketEvent( testing_clock_->NowTicks(), - kVideoPacketRetransmitted, + PACKET_SENT_TO_NETWORK, + VIDEO_EVENT, rtp_timestamp, /*frame_id*/ 0, 0, diff --git a/media/cast/logging/logging_defines.cc b/media/cast/logging/logging_defines.cc index bcb9c37..d0dd5c8 100644 --- a/media/cast/logging/logging_defines.cc +++ b/media/cast/logging/logging_defines.cc @@ -7,7 +7,7 @@ #include "base/logging.h" #define ENUM_TO_STRING(enum) \ - case k##enum: \ + case enum: \ return #enum namespace media { @@ -15,80 +15,25 @@ namespace cast { const char* CastLoggingToString(CastLoggingEvent event) { switch (event) { - // Can happen if the sender and receiver of RTCP log messages are not - // aligned. - ENUM_TO_STRING(Unknown); - ENUM_TO_STRING(RttMs); - ENUM_TO_STRING(PacketLoss); - ENUM_TO_STRING(JitterMs); - ENUM_TO_STRING(VideoAckReceived); - ENUM_TO_STRING(RembBitrate); - ENUM_TO_STRING(AudioAckSent); - ENUM_TO_STRING(VideoAckSent); - ENUM_TO_STRING(AudioFrameCaptureBegin); - ENUM_TO_STRING(AudioFrameCaptureEnd); - ENUM_TO_STRING(AudioFrameEncoded); - ENUM_TO_STRING(AudioPlayoutDelay); - ENUM_TO_STRING(AudioFrameDecoded); - ENUM_TO_STRING(VideoFrameCaptureBegin); - ENUM_TO_STRING(VideoFrameCaptureEnd); - ENUM_TO_STRING(VideoFrameSentToEncoder); - ENUM_TO_STRING(VideoFrameEncoded); - ENUM_TO_STRING(VideoFrameDecoded); - ENUM_TO_STRING(VideoRenderDelay); - ENUM_TO_STRING(AudioPacketSentToNetwork); - ENUM_TO_STRING(VideoPacketSentToNetwork); - ENUM_TO_STRING(AudioPacketRetransmitted); - ENUM_TO_STRING(VideoPacketRetransmitted); - ENUM_TO_STRING(AudioPacketReceived); - ENUM_TO_STRING(VideoPacketReceived); - ENUM_TO_STRING(DuplicateAudioPacketReceived); - ENUM_TO_STRING(DuplicateVideoPacketReceived); + ENUM_TO_STRING(UNKNOWN); + ENUM_TO_STRING(FRAME_CAPTURE_BEGIN); + ENUM_TO_STRING(FRAME_CAPTURE_END); + ENUM_TO_STRING(FRAME_ENCODED); + ENUM_TO_STRING(FRAME_ACK_RECEIVED); + ENUM_TO_STRING(FRAME_ACK_SENT); + ENUM_TO_STRING(FRAME_DECODED); + ENUM_TO_STRING(FRAME_PLAYOUT); + ENUM_TO_STRING(PACKET_SENT_TO_NETWORK); + ENUM_TO_STRING(PACKET_RETRANSMITTED); + ENUM_TO_STRING(PACKET_RECEIVED); } NOTREACHED(); return ""; } -EventMediaType GetEventMediaType(CastLoggingEvent event) { - switch (event) { - case kUnknown: - case kRttMs: - case kPacketLoss: - case kJitterMs: - case kRembBitrate: - return OTHER_EVENT; - case kAudioAckSent: - case kAudioFrameCaptureBegin: - case kAudioFrameCaptureEnd: - case kAudioFrameEncoded: - case kAudioPlayoutDelay: - case kAudioFrameDecoded: - case kAudioPacketSentToNetwork: - case kAudioPacketRetransmitted: - case kAudioPacketReceived: - case kDuplicateAudioPacketReceived: - return AUDIO_EVENT; - case kVideoAckReceived: - case kVideoAckSent: - case kVideoFrameCaptureBegin: - case kVideoFrameCaptureEnd: - case kVideoFrameSentToEncoder: - case kVideoFrameEncoded: - case kVideoFrameDecoded: - case kVideoRenderDelay: - case kVideoPacketSentToNetwork: - case kVideoPacketRetransmitted: - case kVideoPacketReceived: - case kDuplicateVideoPacketReceived: - return VIDEO_EVENT; - } - NOTREACHED(); - return OTHER_EVENT; -} - FrameEvent::FrameEvent() - : rtp_timestamp(0u), frame_id(kFrameIdUnknown), size(0u), type(kUnknown), - key_frame(false), target_bitrate(0) {} + : rtp_timestamp(0u), frame_id(kFrameIdUnknown), size(0u), type(UNKNOWN), + media_type(UNKNOWN_EVENT), key_frame(false), target_bitrate(0) {} FrameEvent::~FrameEvent() {} PacketEvent::PacketEvent() @@ -97,7 +42,8 @@ PacketEvent::PacketEvent() max_packet_id(0), packet_id(0), size(0), - type(kUnknown) {} + type(UNKNOWN), + media_type(UNKNOWN_EVENT) {} PacketEvent::~PacketEvent() {} } // namespace cast diff --git a/media/cast/logging/logging_defines.h b/media/cast/logging/logging_defines.h index f1d5c81..2af95d6 100644 --- a/media/cast/logging/logging_defines.h +++ b/media/cast/logging/logging_defines.h @@ -19,50 +19,28 @@ static const uint32 kFrameIdUnknown = 0xFFFFFFFF; typedef uint32 RtpTimestamp; enum CastLoggingEvent { - kUnknown, - // Generic events. These are no longer used. - kRttMs, - kPacketLoss, - kJitterMs, - kVideoAckReceived, // Sender side frame event. - kRembBitrate, // Generic event. No longer used. + UNKNOWN, + // Sender side frame events. + FRAME_CAPTURE_BEGIN, + FRAME_CAPTURE_END, + FRAME_ENCODED, + FRAME_ACK_RECEIVED, // Receiver side frame events. - kAudioAckSent, - kVideoAckSent, - // Audio sender. - kAudioFrameCaptureBegin, - kAudioFrameCaptureEnd, - kAudioFrameEncoded, - // Audio receiver. - kAudioFrameDecoded, - kAudioPlayoutDelay, - // Video sender. - kVideoFrameCaptureBegin, - kVideoFrameCaptureEnd, - kVideoFrameSentToEncoder, // Deprecated - kVideoFrameEncoded, - // Video receiver. - kVideoFrameDecoded, - kVideoRenderDelay, - // Send-side packet events. - kAudioPacketSentToNetwork, - kVideoPacketSentToNetwork, - kAudioPacketRetransmitted, - kVideoPacketRetransmitted, - // Receive-side packet events. - kAudioPacketReceived, - kVideoPacketReceived, - kDuplicateAudioPacketReceived, - kDuplicateVideoPacketReceived, - kNumOfLoggingEvents = kDuplicateVideoPacketReceived + FRAME_ACK_SENT, + FRAME_DECODED, + FRAME_PLAYOUT, + // Sender side packet events. + PACKET_SENT_TO_NETWORK, + PACKET_RETRANSMITTED, + // Receiver side packet events. + PACKET_RECEIVED, + kNumOfLoggingEvents = PACKET_RECEIVED }; const char* CastLoggingToString(CastLoggingEvent event); // CastLoggingEvent are classified into one of three following types. -enum EventMediaType { AUDIO_EVENT, VIDEO_EVENT, OTHER_EVENT }; - -EventMediaType GetEventMediaType(CastLoggingEvent event); +enum EventMediaType { AUDIO_EVENT, VIDEO_EVENT, UNKNOWN_EVENT }; struct FrameEvent { FrameEvent(); @@ -70,7 +48,8 @@ struct FrameEvent { RtpTimestamp rtp_timestamp; uint32 frame_id; - // Size of encoded frame. Only set for kVideoFrameEncoded event. + + // Size of encoded frame. Only set for FRAME_ENCODED event. size_t size; // Time of event logged. @@ -78,15 +57,16 @@ struct FrameEvent { CastLoggingEvent type; - // Render / playout delay. Only set for kAudioPlayoutDelay and - // kVideoRenderDelay events. + EventMediaType media_type; + + // Render / playout delay. Only set for FRAME_PLAYOUT events. base::TimeDelta delay_delta; - // Whether the frame is a key frame. Only set for kVideoFrameEncoded event. + // Whether the frame is a key frame. Only set for video FRAME_ENCODED event. bool key_frame; // The requested target bitrate of the encoder at the time the frame is - // encoded. Only set for kVideoFrameEncoded event. + // encoded. Only set for video FRAME_ENCODED event. int target_bitrate; }; @@ -103,6 +83,7 @@ struct PacketEvent { // Time of event logged. base::TimeTicks timestamp; CastLoggingEvent type; + EventMediaType media_type; }; } // namespace cast diff --git a/media/cast/logging/logging_impl.cc b/media/cast/logging/logging_impl.cc index 7d975e2..1143d1b 100644 --- a/media/cast/logging/logging_impl.cc +++ b/media/cast/logging/logging_impl.cc @@ -19,33 +19,39 @@ LoggingImpl::LoggingImpl() { LoggingImpl::~LoggingImpl() {} void LoggingImpl::InsertFrameEvent(const base::TimeTicks& time_of_event, - CastLoggingEvent event, uint32 rtp_timestamp, + CastLoggingEvent event, + EventMediaType event_media_type, + uint32 rtp_timestamp, uint32 frame_id) { DCHECK(thread_checker_.CalledOnValidThread()); - raw_.InsertFrameEvent(time_of_event, event, rtp_timestamp, frame_id); + raw_.InsertFrameEvent(time_of_event, event, event_media_type, + rtp_timestamp, frame_id); } void LoggingImpl::InsertEncodedFrameEvent(const base::TimeTicks& time_of_event, CastLoggingEvent event, + EventMediaType event_media_type, uint32 rtp_timestamp, uint32 frame_id, int frame_size, bool key_frame, int target_bitrate) { DCHECK(thread_checker_.CalledOnValidThread()); - raw_.InsertEncodedFrameEvent(time_of_event, event, rtp_timestamp, frame_id, - frame_size, key_frame, target_bitrate); + raw_.InsertEncodedFrameEvent(time_of_event, event, event_media_type, + rtp_timestamp, frame_id, frame_size, key_frame, target_bitrate); } void LoggingImpl::InsertFrameEventWithDelay( const base::TimeTicks& time_of_event, CastLoggingEvent event, - uint32 rtp_timestamp, uint32 frame_id, base::TimeDelta delay) { + EventMediaType event_media_type, uint32 rtp_timestamp, uint32 frame_id, + base::TimeDelta delay) { DCHECK(thread_checker_.CalledOnValidThread()); - raw_.InsertFrameEventWithDelay(time_of_event, event, rtp_timestamp, - frame_id, delay); + raw_.InsertFrameEventWithDelay(time_of_event, event, event_media_type, + rtp_timestamp, frame_id, delay); } void LoggingImpl::InsertSinglePacketEvent(const base::TimeTicks& time_of_event, CastLoggingEvent event, + EventMediaType event_media_type, const Packet& packet) { DCHECK(thread_checker_.CalledOnValidThread()); @@ -64,6 +70,7 @@ void LoggingImpl::InsertSinglePacketEvent(const base::TimeTicks& time_of_event, // rtp_timestamp is enough - no need for frame_id as well. InsertPacketEvent(time_of_event, event, + event_media_type, rtp_timestamp, kFrameIdUnknown, packet_id, @@ -73,22 +80,25 @@ void LoggingImpl::InsertSinglePacketEvent(const base::TimeTicks& time_of_event, void LoggingImpl::InsertPacketListEvent(const base::TimeTicks& time_of_event, CastLoggingEvent event, + EventMediaType event_media_type, const PacketList& packets) { DCHECK(thread_checker_.CalledOnValidThread()); for (PacketList::const_iterator it = packets.begin(); it != packets.end(); ++it) { - InsertSinglePacketEvent(time_of_event, event, (*it)->data); + InsertSinglePacketEvent(time_of_event, event, event_media_type, + (*it)->data); } } void LoggingImpl::InsertPacketEvent(const base::TimeTicks& time_of_event, CastLoggingEvent event, + EventMediaType event_media_type, uint32 rtp_timestamp, uint32 frame_id, uint16 packet_id, uint16 max_packet_id, size_t size) { DCHECK(thread_checker_.CalledOnValidThread()); - raw_.InsertPacketEvent(time_of_event, event, rtp_timestamp, frame_id, - packet_id, max_packet_id, size); + raw_.InsertPacketEvent(time_of_event, event, event_media_type, + rtp_timestamp, frame_id, packet_id, max_packet_id, size); } void LoggingImpl::AddRawEventSubscriber(RawEventSubscriber* subscriber) { diff --git a/media/cast/logging/logging_impl.h b/media/cast/logging/logging_impl.h index 2efef55..ba453c8 100644 --- a/media/cast/logging/logging_impl.h +++ b/media/cast/logging/logging_impl.h @@ -26,27 +26,35 @@ class LoggingImpl { // Note: All methods below should be called from the same thread. void InsertFrameEvent(const base::TimeTicks& time_of_event, - CastLoggingEvent event, uint32 rtp_timestamp, - uint32 frame_id); + CastLoggingEvent event, EventMediaType event_media_type, + uint32 rtp_timestamp, uint32 frame_id); void InsertEncodedFrameEvent(const base::TimeTicks& time_of_event, - CastLoggingEvent event, uint32 rtp_timestamp, - uint32 frame_id, int frame_size, bool key_frame, + CastLoggingEvent event, + EventMediaType event_media_type, + uint32 rtp_timestamp, uint32 frame_id, + int frame_size, bool key_frame, int target_bitrate); void InsertFrameEventWithDelay(const base::TimeTicks& time_of_event, - CastLoggingEvent event, uint32 rtp_timestamp, - uint32 frame_id, base::TimeDelta delay); + CastLoggingEvent event, + EventMediaType event_media_type, + uint32 rtp_timestamp, uint32 frame_id, + base::TimeDelta delay); void InsertSinglePacketEvent(const base::TimeTicks& time_of_event, CastLoggingEvent event, + EventMediaType event_media_type, const Packet& packet); void InsertPacketListEvent(const base::TimeTicks& time_of_event, - CastLoggingEvent event, const PacketList& packets); + CastLoggingEvent event, + EventMediaType event_media_type, + const PacketList& packets); void InsertPacketEvent(const base::TimeTicks& time_of_event, - CastLoggingEvent event, uint32 rtp_timestamp, + CastLoggingEvent event, + EventMediaType event_media_type, uint32 rtp_timestamp, uint32 frame_id, uint16 packet_id, uint16 max_packet_id, size_t size); diff --git a/media/cast/logging/logging_impl_unittest.cc b/media/cast/logging/logging_impl_unittest.cc index cced0ac..712d76b 100644 --- a/media/cast/logging/logging_impl_unittest.cc +++ b/media/cast/logging/logging_impl_unittest.cc @@ -53,7 +53,7 @@ TEST_F(LoggingImplTest, BasicFrameLogging) { do { now = testing_clock_.NowTicks(); logging_.InsertFrameEvent( - now, kAudioFrameCaptureBegin, rtp_timestamp, frame_id); + now, FRAME_CAPTURE_BEGIN, VIDEO_EVENT, rtp_timestamp, frame_id); testing_clock_.Advance( base::TimeDelta::FromMilliseconds(kFrameIntervalMs)); rtp_timestamp += kFrameIntervalMs * 90; @@ -84,7 +84,7 @@ TEST_F(LoggingImplTest, FrameLoggingWithSize) { base::RandInt(-kRandomSizeInterval, kRandomSizeInterval); sum_size += static_cast<size_t>(size); logging_.InsertEncodedFrameEvent(testing_clock_.NowTicks(), - kVideoFrameEncoded, rtp_timestamp, + FRAME_ENCODED, VIDEO_EVENT, rtp_timestamp, frame_id, size, true, target_bitrate); testing_clock_.Advance(base::TimeDelta::FromMilliseconds(kFrameIntervalMs)); rtp_timestamp += kFrameIntervalMs * 90; @@ -112,7 +112,8 @@ TEST_F(LoggingImplTest, FrameLoggingWithDelay) { base::RandInt(-kRandomSizeInterval, kRandomSizeInterval); logging_.InsertFrameEventWithDelay( testing_clock_.NowTicks(), - kAudioFrameCaptureBegin, + FRAME_CAPTURE_BEGIN, + VIDEO_EVENT, rtp_timestamp, frame_id, base::TimeDelta::FromMilliseconds(delay)); @@ -136,21 +137,23 @@ TEST_F(LoggingImplTest, MultipleEventFrameLogging) { uint32 num_events = 0u; do { logging_.InsertFrameEvent(testing_clock_.NowTicks(), - kAudioFrameCaptureBegin, + FRAME_CAPTURE_END, + VIDEO_EVENT, rtp_timestamp, frame_id); ++num_events; if (frame_id % 2) { logging_.InsertEncodedFrameEvent(testing_clock_.NowTicks(), - kAudioFrameEncoded, rtp_timestamp, + FRAME_ENCODED, AUDIO_EVENT, + rtp_timestamp, frame_id, 1500, true, 0); } else if (frame_id % 3) { - logging_.InsertFrameEvent(testing_clock_.NowTicks(), kVideoFrameDecoded, - rtp_timestamp, frame_id); + logging_.InsertFrameEvent(testing_clock_.NowTicks(), FRAME_DECODED, + VIDEO_EVENT, rtp_timestamp, frame_id); } else { logging_.InsertFrameEventWithDelay( - testing_clock_.NowTicks(), kVideoRenderDelay, rtp_timestamp, frame_id, - base::TimeDelta::FromMilliseconds(20)); + testing_clock_.NowTicks(), FRAME_PLAYOUT, VIDEO_EVENT, + rtp_timestamp, frame_id, base::TimeDelta::FromMilliseconds(20)); } ++num_events; @@ -185,12 +188,13 @@ TEST_F(LoggingImplTest, PacketLogging) { latest_time = testing_clock_.NowTicks(); ++num_packets; logging_.InsertPacketEvent(latest_time, - kDuplicateVideoPacketReceived, - rtp_timestamp, - frame_id, - i, - kNumPacketsPerFrame, - size); + PACKET_RECEIVED, + VIDEO_EVENT, + rtp_timestamp, + frame_id, + i, + kNumPacketsPerFrame, + size); } testing_clock_.Advance(base::TimeDelta::FromMilliseconds(kFrameIntervalMs)); rtp_timestamp += kFrameIntervalMs * 90; @@ -211,7 +215,8 @@ TEST_F(LoggingImplTest, MultipleRawEventSubscribers) { logging_.AddRawEventSubscriber(&event_subscriber_2); logging_.InsertFrameEvent(testing_clock_.NowTicks(), - kAudioFrameCaptureBegin, + FRAME_CAPTURE_BEGIN, + VIDEO_EVENT, /*rtp_timestamp*/ 0u, /*frame_id*/ 0u); diff --git a/media/cast/logging/logging_raw.cc b/media/cast/logging/logging_raw.cc index 272f734..229064d 100644 --- a/media/cast/logging/logging_raw.cc +++ b/media/cast/logging/logging_raw.cc @@ -17,32 +17,39 @@ LoggingRaw::LoggingRaw() {} LoggingRaw::~LoggingRaw() {} void LoggingRaw::InsertFrameEvent(const base::TimeTicks& time_of_event, - CastLoggingEvent event, uint32 rtp_timestamp, + CastLoggingEvent event, + EventMediaType event_media_type, + uint32 rtp_timestamp, uint32 frame_id) { - InsertBaseFrameEvent(time_of_event, event, frame_id, rtp_timestamp, - base::TimeDelta(), 0, false, 0); + InsertBaseFrameEvent(time_of_event, event, event_media_type, frame_id, + rtp_timestamp, base::TimeDelta(), 0, false, 0); } void LoggingRaw::InsertEncodedFrameEvent(const base::TimeTicks& time_of_event, CastLoggingEvent event, + EventMediaType event_media_type, uint32 rtp_timestamp, uint32 frame_id, int size, bool key_frame, int target_bitrate) { - InsertBaseFrameEvent(time_of_event, event, frame_id, rtp_timestamp, - base::TimeDelta(), size, key_frame, target_bitrate); + InsertBaseFrameEvent(time_of_event, event, event_media_type, + frame_id, rtp_timestamp, base::TimeDelta(), size, + key_frame, target_bitrate); } void LoggingRaw::InsertFrameEventWithDelay(const base::TimeTicks& time_of_event, CastLoggingEvent event, + EventMediaType event_media_type, uint32 rtp_timestamp, uint32 frame_id, base::TimeDelta delay) { - InsertBaseFrameEvent(time_of_event, event, frame_id, rtp_timestamp, delay, - 0, false, 0); + InsertBaseFrameEvent(time_of_event, event, event_media_type, frame_id, + rtp_timestamp, delay, 0, false, 0); } void LoggingRaw::InsertBaseFrameEvent(const base::TimeTicks& time_of_event, - CastLoggingEvent event, uint32 frame_id, + CastLoggingEvent event, + EventMediaType event_media_type, + uint32 frame_id, uint32 rtp_timestamp, base::TimeDelta delay, int size, bool key_frame, int target_bitrate) { @@ -52,6 +59,7 @@ void LoggingRaw::InsertBaseFrameEvent(const base::TimeTicks& time_of_event, frame_event.size = size; frame_event.timestamp = time_of_event; frame_event.type = event; + frame_event.media_type = event_media_type; frame_event.delay_delta = delay; frame_event.key_frame = key_frame; frame_event.target_bitrate = target_bitrate; @@ -63,7 +71,9 @@ void LoggingRaw::InsertBaseFrameEvent(const base::TimeTicks& time_of_event, } void LoggingRaw::InsertPacketEvent(const base::TimeTicks& time_of_event, - CastLoggingEvent event, uint32 rtp_timestamp, + CastLoggingEvent event, + EventMediaType event_media_type, + uint32 rtp_timestamp, uint32 frame_id, uint16 packet_id, uint16 max_packet_id, size_t size) { PacketEvent packet_event; @@ -74,6 +84,7 @@ void LoggingRaw::InsertPacketEvent(const base::TimeTicks& time_of_event, packet_event.size = size; packet_event.timestamp = time_of_event; packet_event.type = event; + packet_event.media_type = event_media_type; for (std::vector<RawEventSubscriber*>::const_iterator it = subscribers_.begin(); it != subscribers_.end(); ++it) { diff --git a/media/cast/logging/logging_raw.h b/media/cast/logging/logging_raw.h index 98c2bfe..8ed4a59 100644 --- a/media/cast/logging/logging_raw.h +++ b/media/cast/logging/logging_raw.h @@ -27,31 +27,34 @@ class LoggingRaw : public base::NonThreadSafe { // Inform of new event: two types of events: frame and packet. // Frame events can be inserted with different parameters. void InsertFrameEvent(const base::TimeTicks& time_of_event, - CastLoggingEvent event, uint32 rtp_timestamp, - uint32 frame_id); + CastLoggingEvent event, EventMediaType event_media_type, + uint32 rtp_timestamp, uint32 frame_id); - // This function is only applicable for the following frame events: - // kAudioFrameEncoded, kVideoFrameEncoded + // This function is only applicable for FRAME_ENCODED event. // |size| - Size of encoded frame. // |key_frame| - Whether the frame is a key frame. This field is only - // applicable for kVideoFrameEncoded event. + // applicable for video event. // |target_bitrate| - The target bitrate of the encoder the time the frame - // was encoded. Only applicable for kVideoFrameEncoded event. + // was encoded. Only applicable for video event. void InsertEncodedFrameEvent(const base::TimeTicks& time_of_event, - CastLoggingEvent event, uint32 rtp_timestamp, - uint32 frame_id, int size, bool key_frame, + CastLoggingEvent event, + EventMediaType event_media_type, + uint32 rtp_timestamp, uint32 frame_id, + int size, bool key_frame, int target_bitrate); // Render/playout delay - // This function is only applicable for the following frame events: - // kAudioPlayoutDelay, kVideoRenderDelay + // This function is only applicable for FRAME_PLAYOUT event. void InsertFrameEventWithDelay(const base::TimeTicks& time_of_event, - CastLoggingEvent event, uint32 rtp_timestamp, + CastLoggingEvent event, + EventMediaType event_media_type, + uint32 rtp_timestamp, uint32 frame_id, base::TimeDelta delay); // Insert a packet event. void InsertPacketEvent(const base::TimeTicks& time_of_event, - CastLoggingEvent event, uint32 rtp_timestamp, + CastLoggingEvent event, + EventMediaType event_media_type, uint32 rtp_timestamp, uint32 frame_id, uint16 packet_id, uint16 max_packet_id, size_t size); @@ -68,9 +71,11 @@ class LoggingRaw : public base::NonThreadSafe { private: void InsertBaseFrameEvent(const base::TimeTicks& time_of_event, - CastLoggingEvent event, uint32 frame_id, - uint32 rtp_timestamp, base::TimeDelta delay, - int size, bool key_frame, int target_bitrate); + CastLoggingEvent event, + EventMediaType event_media_type, + uint32 frame_id, uint32 rtp_timestamp, + base::TimeDelta delay, int size, bool key_frame, + int target_bitrate); // List of subscriber pointers. This class does not own the subscribers. std::vector<RawEventSubscriber*> subscribers_; diff --git a/media/cast/logging/logging_raw_unittest.cc b/media/cast/logging/logging_raw_unittest.cc index 0949cd9..0b7c05a 100644 --- a/media/cast/logging/logging_raw_unittest.cc +++ b/media/cast/logging/logging_raw_unittest.cc @@ -25,11 +25,13 @@ class LoggingRawTest : public ::testing::Test { }; TEST_F(LoggingRawTest, FrameEvent) { - CastLoggingEvent event_type = kVideoFrameDecoded; + CastLoggingEvent event_type = FRAME_DECODED; + EventMediaType media_type = VIDEO_EVENT; uint32 frame_id = 456u; RtpTimestamp rtp_timestamp = 123u; base::TimeTicks timestamp = base::TimeTicks(); - raw_.InsertFrameEvent(timestamp, event_type, rtp_timestamp, frame_id); + raw_.InsertFrameEvent(timestamp, event_type, media_type, + rtp_timestamp, frame_id); event_subscriber_.GetPacketEventsAndReset(&packet_events_); EXPECT_TRUE(packet_events_.empty()); @@ -41,19 +43,21 @@ TEST_F(LoggingRawTest, FrameEvent) { EXPECT_EQ(0u, frame_events_[0].size); EXPECT_EQ(timestamp, frame_events_[0].timestamp); EXPECT_EQ(event_type, frame_events_[0].type); + EXPECT_EQ(media_type, frame_events_[0].media_type); EXPECT_EQ(base::TimeDelta(), frame_events_[0].delay_delta); } TEST_F(LoggingRawTest, EncodedFrameEvent) { - CastLoggingEvent event_type = kVideoFrameEncoded; + CastLoggingEvent event_type = FRAME_ENCODED; + EventMediaType media_type = VIDEO_EVENT; uint32 frame_id = 456u; RtpTimestamp rtp_timestamp = 123u; base::TimeTicks timestamp = base::TimeTicks(); int size = 1024; bool key_frame = true; int target_bitrate = 4096; - raw_.InsertEncodedFrameEvent(timestamp, event_type, rtp_timestamp, frame_id, - size, key_frame, target_bitrate); + raw_.InsertEncodedFrameEvent(timestamp, event_type, media_type, + rtp_timestamp, frame_id, size, key_frame, target_bitrate); event_subscriber_.GetPacketEventsAndReset(&packet_events_); EXPECT_TRUE(packet_events_.empty()); @@ -65,19 +69,21 @@ TEST_F(LoggingRawTest, EncodedFrameEvent) { EXPECT_EQ(size, static_cast<int>(frame_events_[0].size)); EXPECT_EQ(timestamp, frame_events_[0].timestamp); EXPECT_EQ(event_type, frame_events_[0].type); + EXPECT_EQ(media_type, frame_events_[0].media_type); EXPECT_EQ(base::TimeDelta(), frame_events_[0].delay_delta); EXPECT_EQ(key_frame, frame_events_[0].key_frame); EXPECT_EQ(target_bitrate, frame_events_[0].target_bitrate); } TEST_F(LoggingRawTest, FrameEventWithDelay) { - CastLoggingEvent event_type = kVideoRenderDelay; + CastLoggingEvent event_type = FRAME_PLAYOUT; + EventMediaType media_type = VIDEO_EVENT; uint32 frame_id = 456u; RtpTimestamp rtp_timestamp = 123u; base::TimeTicks timestamp = base::TimeTicks(); base::TimeDelta delay = base::TimeDelta::FromMilliseconds(20); - raw_.InsertFrameEventWithDelay(timestamp, event_type, rtp_timestamp, frame_id, - delay); + raw_.InsertFrameEventWithDelay(timestamp, event_type, media_type, + rtp_timestamp, frame_id, delay); event_subscriber_.GetPacketEventsAndReset(&packet_events_); EXPECT_TRUE(packet_events_.empty()); @@ -89,25 +95,28 @@ TEST_F(LoggingRawTest, FrameEventWithDelay) { EXPECT_EQ(0u, frame_events_[0].size); EXPECT_EQ(timestamp, frame_events_[0].timestamp); EXPECT_EQ(event_type, frame_events_[0].type); + EXPECT_EQ(media_type, frame_events_[0].media_type); EXPECT_EQ(delay, frame_events_[0].delay_delta); } TEST_F(LoggingRawTest, PacketEvent) { - CastLoggingEvent event_type = kVideoPacketReceived; + CastLoggingEvent event_type = PACKET_RECEIVED; + EventMediaType media_type = VIDEO_EVENT; uint32 frame_id = 456u; uint16 packet_id = 1u; uint16 max_packet_id = 10u; RtpTimestamp rtp_timestamp = 123u; base::TimeTicks timestamp = base::TimeTicks(); size_t size = 1024u; - raw_.InsertPacketEvent(timestamp, event_type, rtp_timestamp, frame_id, - packet_id, max_packet_id, size); + raw_.InsertPacketEvent(timestamp, event_type, media_type, + rtp_timestamp, frame_id, packet_id, max_packet_id, size); event_subscriber_.GetFrameEventsAndReset(&frame_events_); EXPECT_TRUE(frame_events_.empty()); event_subscriber_.GetPacketEventsAndReset(&packet_events_); ASSERT_EQ(1u, packet_events_.size()); + EXPECT_EQ(rtp_timestamp, packet_events_[0].rtp_timestamp); EXPECT_EQ(frame_id, packet_events_[0].frame_id); EXPECT_EQ(max_packet_id, packet_events_[0].max_packet_id); @@ -115,6 +124,7 @@ TEST_F(LoggingRawTest, PacketEvent) { EXPECT_EQ(size, packet_events_[0].size); EXPECT_EQ(timestamp, packet_events_[0].timestamp); EXPECT_EQ(event_type, packet_events_[0].type); + EXPECT_EQ(media_type, packet_events_[0].media_type); } TEST_F(LoggingRawTest, MultipleSubscribers) { @@ -123,11 +133,13 @@ TEST_F(LoggingRawTest, MultipleSubscribers) { // Now raw_ has two subscribers. raw_.AddSubscriber(&event_subscriber_2); - CastLoggingEvent event_type = kVideoFrameDecoded; + CastLoggingEvent event_type = FRAME_DECODED; + EventMediaType media_type = VIDEO_EVENT; uint32 frame_id = 456u; RtpTimestamp rtp_timestamp = 123u; base::TimeTicks timestamp = base::TimeTicks(); - raw_.InsertFrameEvent(timestamp, event_type, rtp_timestamp, frame_id); + raw_.InsertFrameEvent(timestamp, event_type, media_type, + rtp_timestamp, frame_id); event_subscriber_.GetPacketEventsAndReset(&packet_events_); EXPECT_TRUE(packet_events_.empty()); @@ -139,6 +151,7 @@ TEST_F(LoggingRawTest, MultipleSubscribers) { EXPECT_EQ(0u, frame_events_[0].size); EXPECT_EQ(timestamp, frame_events_[0].timestamp); EXPECT_EQ(event_type, frame_events_[0].type); + EXPECT_EQ(media_type, frame_events_[0].media_type); EXPECT_EQ(base::TimeDelta(), frame_events_[0].delay_delta); event_subscriber_2.GetPacketEventsAndReset(&packet_events_); @@ -151,16 +164,18 @@ TEST_F(LoggingRawTest, MultipleSubscribers) { EXPECT_EQ(0u, frame_events_[0].size); EXPECT_EQ(timestamp, frame_events_[0].timestamp); EXPECT_EQ(event_type, frame_events_[0].type); + EXPECT_EQ(media_type, frame_events_[0].media_type); EXPECT_EQ(base::TimeDelta(), frame_events_[0].delay_delta); // Remove event_subscriber_2, so it shouldn't receive events after this. raw_.RemoveSubscriber(&event_subscriber_2); - event_type = kAudioFrameDecoded; + media_type = AUDIO_EVENT; frame_id = 789; rtp_timestamp = 456; timestamp = base::TimeTicks(); - raw_.InsertFrameEvent(timestamp, event_type, rtp_timestamp, frame_id); + raw_.InsertFrameEvent(timestamp, event_type, media_type, + rtp_timestamp, frame_id); // |event_subscriber_| should still receive events. event_subscriber_.GetFrameEventsAndReset(&frame_events_); @@ -170,6 +185,7 @@ TEST_F(LoggingRawTest, MultipleSubscribers) { EXPECT_EQ(0u, frame_events_[0].size); EXPECT_EQ(timestamp, frame_events_[0].timestamp); EXPECT_EQ(event_type, frame_events_[0].type); + EXPECT_EQ(media_type, frame_events_[0].media_type); EXPECT_EQ(base::TimeDelta(), frame_events_[0].delay_delta); event_subscriber_2.GetFrameEventsAndReset(&frame_events_); diff --git a/media/cast/logging/proto/proto_utils.cc b/media/cast/logging/proto/proto_utils.cc index 90517e1..1f05616 100644 --- a/media/cast/logging/proto/proto_utils.cc +++ b/media/cast/logging/proto/proto_utils.cc @@ -6,47 +6,29 @@ #include "base/logging.h" -#define TO_PROTO_ENUM(from_enum, to_enum) \ - case from_enum: \ - return media::cast::proto::to_enum +#define TO_PROTO_ENUM(enum) \ + case enum: \ + return proto::enum namespace media { namespace cast { -media::cast::proto::EventType ToProtoEventType(CastLoggingEvent event) { +proto::EventType ToProtoEventType(CastLoggingEvent event) { switch (event) { - TO_PROTO_ENUM(kUnknown, UNKNOWN); - TO_PROTO_ENUM(kRttMs, RTT_MS); - TO_PROTO_ENUM(kPacketLoss, PACKET_LOSS); - TO_PROTO_ENUM(kJitterMs, JITTER_MS); - TO_PROTO_ENUM(kVideoAckReceived, VIDEO_ACK_RECEIVED); - TO_PROTO_ENUM(kRembBitrate, REMB_BITRATE); - TO_PROTO_ENUM(kAudioAckSent, AUDIO_ACK_SENT); - TO_PROTO_ENUM(kVideoAckSent, VIDEO_ACK_SENT); - TO_PROTO_ENUM(kAudioFrameCaptureEnd, AUDIO_FRAME_CAPTURE_END); - TO_PROTO_ENUM(kAudioFrameCaptureBegin, AUDIO_FRAME_CAPTURE_BEGIN); - TO_PROTO_ENUM(kAudioFrameEncoded, AUDIO_FRAME_ENCODED); - TO_PROTO_ENUM(kAudioPlayoutDelay, AUDIO_PLAYOUT_DELAY); - TO_PROTO_ENUM(kAudioFrameDecoded, AUDIO_FRAME_DECODED); - TO_PROTO_ENUM(kVideoFrameCaptureBegin, VIDEO_FRAME_CAPTURE_BEGIN); - TO_PROTO_ENUM(kVideoFrameCaptureEnd, VIDEO_FRAME_CAPTURE_END); - TO_PROTO_ENUM(kVideoFrameSentToEncoder, VIDEO_FRAME_SENT_TO_ENCODER); - TO_PROTO_ENUM(kVideoFrameEncoded, VIDEO_FRAME_ENCODED); - TO_PROTO_ENUM(kVideoFrameDecoded, VIDEO_FRAME_DECODED); - TO_PROTO_ENUM(kVideoRenderDelay, VIDEO_RENDER_DELAY); - TO_PROTO_ENUM(kAudioPacketSentToNetwork, AUDIO_PACKET_SENT_TO_NETWORK); - TO_PROTO_ENUM(kVideoPacketSentToNetwork, VIDEO_PACKET_SENT_TO_NETWORK); - TO_PROTO_ENUM(kAudioPacketRetransmitted, AUDIO_PACKET_RETRANSMITTED); - TO_PROTO_ENUM(kVideoPacketRetransmitted, VIDEO_PACKET_RETRANSMITTED); - TO_PROTO_ENUM(kAudioPacketReceived, AUDIO_PACKET_RECEIVED); - TO_PROTO_ENUM(kVideoPacketReceived, VIDEO_PACKET_RECEIVED); - TO_PROTO_ENUM(kDuplicateAudioPacketReceived, - DUPLICATE_AUDIO_PACKET_RECEIVED); - TO_PROTO_ENUM(kDuplicateVideoPacketReceived, - DUPLICATE_VIDEO_PACKET_RECEIVED); + TO_PROTO_ENUM(UNKNOWN); + TO_PROTO_ENUM(FRAME_CAPTURE_BEGIN); + TO_PROTO_ENUM(FRAME_CAPTURE_END); + TO_PROTO_ENUM(FRAME_ENCODED); + TO_PROTO_ENUM(FRAME_ACK_RECEIVED); + TO_PROTO_ENUM(FRAME_ACK_SENT); + TO_PROTO_ENUM(FRAME_DECODED); + TO_PROTO_ENUM(FRAME_PLAYOUT); + TO_PROTO_ENUM(PACKET_SENT_TO_NETWORK); + TO_PROTO_ENUM(PACKET_RETRANSMITTED); + TO_PROTO_ENUM(PACKET_RECEIVED); } NOTREACHED(); - return media::cast::proto::UNKNOWN; + return proto::UNKNOWN; } } // namespace cast diff --git a/media/cast/logging/proto/raw_events.proto b/media/cast/logging/proto/raw_events.proto index adbd943..2ffed58 100644 --- a/media/cast/logging/proto/raw_events.proto +++ b/media/cast/logging/proto/raw_events.proto @@ -14,6 +14,8 @@ package media.cast.proto; // For compatibility reasons, existing values in this enum must not be changed. enum EventType { UNKNOWN = 0; + + // Note: 1-28 are deprecated in favor of unified event types. Do not use. // Generic events. No longer used. RTT_MS = 1; PACKET_LOSS = 2; @@ -51,6 +53,19 @@ enum EventType { VIDEO_PACKET_RECEIVED = 26; DUPLICATE_AUDIO_PACKET_RECEIVED = 27; DUPLICATE_VIDEO_PACKET_RECEIVED = 28; + + + // New, unified event types. + FRAME_CAPTURE_BEGIN = 29; + FRAME_CAPTURE_END = 30; + FRAME_ENCODED = 31; + FRAME_ACK_RECEIVED = 32; + FRAME_ACK_SENT = 33; + FRAME_DECODED = 34; + FRAME_PLAYOUT = 35; + PACKET_SENT_TO_NETWORK = 36; + PACKET_RETRANSMITTED = 37; + PACKET_RECEIVED = 38; } // Each log will contain one |LogMetadata|. @@ -86,16 +101,16 @@ message AggregatedFrameEvent { // and date. repeated int64 event_timestamp_ms = 3 [packed = true]; - // Only set if there is a kAudioFrameEncoded and kVideoFrameEncoded event. + // Only set if there is a frame encoded event. optional int32 encoded_frame_size = 4; - // Only set if there is a kAudioPlayoutDelay or kVideoRenderDelay event. + // Only set if there is a frame playout event. optional int32 delay_millis = 5; - // Only set if there is a kVideoFrameEncoded event. + // Only set if there is a video frame encoded event. optional bool key_frame = 6; - // Only set if there is a kVideoFrameEncoded event. + // Only set if there is a video frame encoded event. optional int32 target_bitrate = 7; }; diff --git a/media/cast/logging/receiver_time_offset_estimator_impl.cc b/media/cast/logging/receiver_time_offset_estimator_impl.cc index 897c7e1..44d5eb0 100644 --- a/media/cast/logging/receiver_time_offset_estimator_impl.cc +++ b/media/cast/logging/receiver_time_offset_estimator_impl.cc @@ -25,9 +25,13 @@ ReceiverTimeOffsetEstimatorImpl::~ReceiverTimeOffsetEstimatorImpl() { void ReceiverTimeOffsetEstimatorImpl::OnReceiveFrameEvent( const FrameEvent& frame_event) { DCHECK(thread_checker_.CalledOnValidThread()); + + if (frame_event.media_type != VIDEO_EVENT) + return; + CastLoggingEvent event = frame_event.type; - if (event != kVideoFrameEncoded && event != kVideoAckSent && - event != kVideoAckReceived) + if (event != FRAME_ENCODED && event != FRAME_ACK_SENT && + event != FRAME_ACK_RECEIVED) return; EventTimesMap::iterator it = event_times_map_.find(frame_event.rtp_timestamp); @@ -37,7 +41,7 @@ void ReceiverTimeOffsetEstimatorImpl::OnReceiveFrameEvent( event_times)).first; } switch (event) { - case kVideoFrameEncoded: + case FRAME_ENCODED: // Encode is supposed to happen only once. If we see duplicate event, // throw away the entry. if (it->second.event_a_time.is_null()) { @@ -47,7 +51,7 @@ void ReceiverTimeOffsetEstimatorImpl::OnReceiveFrameEvent( return; } break; - case kVideoAckSent: + case FRAME_ACK_SENT: if (it->second.event_b_time.is_null()) { it->second.event_b_time = frame_event.timestamp; } else if (it->second.event_b_time != frame_event.timestamp) { @@ -57,7 +61,7 @@ void ReceiverTimeOffsetEstimatorImpl::OnReceiveFrameEvent( return; } break; - case kVideoAckReceived: + case FRAME_ACK_RECEIVED: // If there are duplicate ack received events, pick the one with the // smallest event timestamp so we can get a better bound. if (it->second.event_c_time.is_null()) { diff --git a/media/cast/logging/receiver_time_offset_estimator_impl.h b/media/cast/logging/receiver_time_offset_estimator_impl.h index 0968bed..1d0f6c8 100644 --- a/media/cast/logging/receiver_time_offset_estimator_impl.h +++ b/media/cast/logging/receiver_time_offset_estimator_impl.h @@ -13,10 +13,10 @@ namespace media { namespace cast { -// This implementation listens to three types of events: -// 1. kVideoFrameEncoded (sender side) -// 2. kVideoAckSent (receiver side) -// 3. kVideoAckReceived (sender side) +// This implementation listens to three types of video events: +// 1. FRAME_ENCODED (sender side) +// 2. FRAME_ACK_SENT (receiver side) +// 3. FRAME_ACK_RECEIVED (sender side) // There is a causal relationship between these events in that these events // must happen in order. This class obtains the lower and upper bounds for // the offset by taking the difference of timestamps (2) - (1) and (2) - (3), 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 36985b6..1cdbecf 100644 --- a/media/cast/logging/receiver_time_offset_estimator_impl_unittest.cc +++ b/media/cast/logging/receiver_time_offset_estimator_impl_unittest.cc @@ -65,7 +65,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, EstimateOffset) { cast_environment_->Logging()->InsertEncodedFrameEvent( sender_clock_->NowTicks(), - kVideoFrameEncoded, + FRAME_ENCODED, VIDEO_EVENT, rtp_timestamp, frame_id, 1234, @@ -76,13 +76,15 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, EstimateOffset) { AdvanceClocks(base::TimeDelta::FromMilliseconds(10)); cast_environment_->Logging()->InsertFrameEvent( - receiver_clock_.NowTicks(), kVideoAckSent, rtp_timestamp, frame_id); + receiver_clock_.NowTicks(), FRAME_ACK_SENT, VIDEO_EVENT, + rtp_timestamp, frame_id); EXPECT_FALSE(estimator_.GetReceiverOffsetBounds(&lower_bound, &upper_bound)); AdvanceClocks(base::TimeDelta::FromMilliseconds(30)); cast_environment_->Logging()->InsertFrameEvent( - sender_clock_->NowTicks(), kVideoAckReceived, rtp_timestamp, frame_id); + sender_clock_->NowTicks(), FRAME_ACK_RECEIVED, VIDEO_EVENT, + rtp_timestamp, frame_id); EXPECT_TRUE(estimator_.GetReceiverOffsetBounds(&lower_bound, &upper_bound)); @@ -112,7 +114,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, EventCArrivesBeforeEventB) { cast_environment_->Logging()->InsertEncodedFrameEvent( sender_clock_->NowTicks(), - kVideoFrameEncoded, + FRAME_ENCODED, VIDEO_EVENT, rtp_timestamp, frame_id, 1234, @@ -127,12 +129,12 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, EventCArrivesBeforeEventB) { base::TimeTicks event_c_time = sender_clock_->NowTicks(); cast_environment_->Logging()->InsertFrameEvent( - event_c_time, kVideoAckReceived, rtp_timestamp, frame_id); + event_c_time, FRAME_ACK_RECEIVED, VIDEO_EVENT, rtp_timestamp, frame_id); EXPECT_FALSE(estimator_.GetReceiverOffsetBounds(&lower_bound, &upper_bound)); cast_environment_->Logging()->InsertFrameEvent( - event_b_time, kVideoAckSent, rtp_timestamp, frame_id); + event_b_time, FRAME_ACK_SENT, VIDEO_EVENT, rtp_timestamp, frame_id); EXPECT_TRUE(estimator_.GetReceiverOffsetBounds(&lower_bound, &upper_bound)); @@ -166,7 +168,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, MultipleIterations) { AdvanceClocks(base::TimeDelta::FromMilliseconds(20)); cast_environment_->Logging()->InsertEncodedFrameEvent( sender_clock_->NowTicks(), - kVideoFrameEncoded, + FRAME_ENCODED, VIDEO_EVENT, rtp_timestamp_a, frame_id_a, 1234, @@ -176,35 +178,39 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, MultipleIterations) { AdvanceClocks(base::TimeDelta::FromMilliseconds(10)); cast_environment_->Logging()->InsertEncodedFrameEvent( sender_clock_->NowTicks(), - kVideoFrameEncoded, + FRAME_ENCODED, VIDEO_EVENT, rtp_timestamp_b, frame_id_b, 1234, true, 5678); cast_environment_->Logging()->InsertFrameEvent( - receiver_clock_.NowTicks(), kVideoAckSent, rtp_timestamp_a, frame_id_a); + receiver_clock_.NowTicks(), FRAME_ACK_SENT, VIDEO_EVENT, + rtp_timestamp_a, frame_id_a); AdvanceClocks(base::TimeDelta::FromMilliseconds(20)); cast_environment_->Logging()->InsertFrameEvent( - receiver_clock_.NowTicks(), kVideoAckSent, rtp_timestamp_b, frame_id_b); + receiver_clock_.NowTicks(), FRAME_ACK_SENT, VIDEO_EVENT, + rtp_timestamp_b, frame_id_b); AdvanceClocks(base::TimeDelta::FromMilliseconds(5)); cast_environment_->Logging()->InsertFrameEvent(sender_clock_->NowTicks(), - kVideoAckReceived, + FRAME_ACK_RECEIVED, + VIDEO_EVENT, rtp_timestamp_b, frame_id_b); AdvanceClocks(base::TimeDelta::FromMilliseconds(5)); cast_environment_->Logging()->InsertFrameEvent(sender_clock_->NowTicks(), - kVideoAckReceived, + FRAME_ACK_RECEIVED, + VIDEO_EVENT, rtp_timestamp_a, frame_id_a); AdvanceClocks(base::TimeDelta::FromMilliseconds(17)); cast_environment_->Logging()->InsertEncodedFrameEvent( sender_clock_->NowTicks(), - kVideoFrameEncoded, + FRAME_ENCODED, VIDEO_EVENT, rtp_timestamp_c, frame_id_c, 1234, @@ -213,11 +219,13 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, MultipleIterations) { AdvanceClocks(base::TimeDelta::FromMilliseconds(3)); cast_environment_->Logging()->InsertFrameEvent( - receiver_clock_.NowTicks(), kVideoAckSent, rtp_timestamp_c, frame_id_c); + receiver_clock_.NowTicks(), FRAME_ACK_SENT, VIDEO_EVENT, + rtp_timestamp_c, frame_id_c); AdvanceClocks(base::TimeDelta::FromMilliseconds(30)); cast_environment_->Logging()->InsertFrameEvent(sender_clock_->NowTicks(), - kVideoAckReceived, + FRAME_ACK_RECEIVED, + VIDEO_EVENT, rtp_timestamp_c, frame_id_c); diff --git a/media/cast/logging/serialize_deserialize_test.cc b/media/cast/logging/serialize_deserialize_test.cc index b309ced..7e5aa7d 100644 --- a/media/cast/logging/serialize_deserialize_test.cc +++ b/media/cast/logging/serialize_deserialize_test.cc @@ -20,18 +20,19 @@ using media::cast::proto::LogMetadata; namespace { const media::cast::CastLoggingEvent kVideoFrameEvents[] = { - media::cast::kVideoFrameCaptureBegin, media::cast::kVideoFrameCaptureEnd, - media::cast::kVideoFrameSentToEncoder, media::cast::kVideoFrameEncoded, - media::cast::kVideoFrameDecoded, media::cast::kVideoRenderDelay}; + media::cast::FRAME_CAPTURE_BEGIN, media::cast::FRAME_CAPTURE_END, + media::cast::FRAME_ENCODED, media::cast::FRAME_DECODED, + media::cast::FRAME_PLAYOUT }; const media::cast::CastLoggingEvent kVideoPacketEvents[] = { - media::cast::kVideoPacketSentToNetwork, media::cast::kVideoPacketReceived}; + media::cast::PACKET_SENT_TO_NETWORK, media::cast::PACKET_RECEIVED}; // The frame event fields cycle through these numbers. const int kEncodedFrameSize[] = {512, 425, 399, 400, 237}; const int kDelayMillis[] = {15, 4, 8, 42, 23, 16}; const int kMaxSerializedBytes = 10000; + } namespace media { diff --git a/media/cast/logging/simple_event_subscriber_unittest.cc b/media/cast/logging/simple_event_subscriber_unittest.cc index bce7f53..311a234 100644 --- a/media/cast/logging/simple_event_subscriber_unittest.cc +++ b/media/cast/logging/simple_event_subscriber_unittest.cc @@ -41,25 +41,31 @@ class SimpleEventSubscriberTest : public ::testing::Test { TEST_F(SimpleEventSubscriberTest, GetAndResetEvents) { // Log some frame events. cast_environment_->Logging()->InsertEncodedFrameEvent( - testing_clock_->NowTicks(), kAudioFrameEncoded, /*rtp_timestamp*/ 100u, - /*frame_id*/ 0u, /*frame_size*/ 123, /*key_frame*/ false, 0); + testing_clock_->NowTicks(), FRAME_ENCODED, AUDIO_EVENT, + /*rtp_timestamp*/ 100u, /*frame_id*/ 0u, /*frame_size*/ 123, + /*key_frame*/ false, 0); cast_environment_->Logging()->InsertFrameEventWithDelay( - testing_clock_->NowTicks(), kAudioPlayoutDelay, /*rtp_timestamp*/ 100u, + testing_clock_->NowTicks(), FRAME_PLAYOUT, AUDIO_EVENT, + /*rtp_timestamp*/ 100u, /*frame_id*/ 0u, /*delay*/ base::TimeDelta::FromMilliseconds(100)); cast_environment_->Logging()->InsertFrameEvent( - testing_clock_->NowTicks(), kAudioFrameDecoded, /*rtp_timestamp*/ 200u, + testing_clock_->NowTicks(), FRAME_DECODED, AUDIO_EVENT, + /*rtp_timestamp*/ 200u, /*frame_id*/ 0u); // Log some packet events. cast_environment_->Logging()->InsertPacketEvent( - testing_clock_->NowTicks(), kAudioPacketReceived, /*rtp_timestamp*/ 200u, + testing_clock_->NowTicks(), PACKET_RECEIVED, AUDIO_EVENT, + /*rtp_timestamp*/ 200u, /*frame_id*/ 0u, /*packet_id*/ 1u, /*max_packet_id*/ 5u, /*size*/ 100u); cast_environment_->Logging()->InsertPacketEvent( - testing_clock_->NowTicks(), kVideoFrameDecoded, /*rtp_timestamp*/ 200u, - /*frame_id*/ 0u, /*packet_id*/ 1u, /*max_packet_id*/ 5u, /*size*/ 100u); + testing_clock_->NowTicks(), FRAME_DECODED, VIDEO_EVENT, + /*rtp_timestamp*/ 200u, /*frame_id*/ 0u, /*packet_id*/ 1u, + /*max_packet_id*/ 5u, /*size*/ 100u); cast_environment_->Logging()->InsertPacketEvent( - testing_clock_->NowTicks(), kVideoFrameDecoded, /*rtp_timestamp*/ 300u, - /*frame_id*/ 0u, /*packet_id*/ 1u, /*max_packet_id*/ 5u, /*size*/ 100u); + testing_clock_->NowTicks(), FRAME_DECODED, VIDEO_EVENT, + /*rtp_timestamp*/ 300u, /*frame_id*/ 0u, /*packet_id*/ 1u, + /*max_packet_id*/ 5u, /*size*/ 100u); std::vector<FrameEvent> frame_events; event_subscriber_.GetFrameEventsAndReset(&frame_events); diff --git a/media/cast/logging/stats_event_subscriber.cc b/media/cast/logging/stats_event_subscriber.cc index e292d66..9e3226a 100644 --- a/media/cast/logging/stats_event_subscriber.cc +++ b/media/cast/logging/stats_event_subscriber.cc @@ -22,49 +22,11 @@ using media::cast::EventMediaType; const size_t kMaxFrameEventTimeMapSize = 100; const size_t kMaxPacketEventTimeMapSize = 1000; -CastLoggingEvent GetCapturedEvent(EventMediaType media_type) { - return media_type == AUDIO_EVENT ? - kAudioFrameCaptureBegin : kVideoFrameCaptureBegin; -} - -CastLoggingEvent GetEncodedEvent(EventMediaType media_type) { - return media_type == AUDIO_EVENT ? kAudioFrameEncoded : kVideoFrameEncoded; -} - -CastLoggingEvent GetDecodedEvent(EventMediaType media_type) { - return media_type == AUDIO_EVENT ? kAudioFrameDecoded : kVideoFrameDecoded; -} - -CastLoggingEvent GetPlayoutEvent(EventMediaType media_type) { - return media_type == AUDIO_EVENT ? kAudioPlayoutDelay : kVideoRenderDelay; -} - -CastLoggingEvent GetPacketSentEvent(EventMediaType media_type) { - return media_type == AUDIO_EVENT ? kAudioPacketSentToNetwork : - kVideoPacketSentToNetwork; -} - -CastLoggingEvent GetPacketReceivedEvent(EventMediaType media_type) { - return media_type == AUDIO_EVENT ? kAudioPacketReceived : - kVideoPacketReceived; -} - -CastLoggingEvent GetPacketRetransmittedEvent(EventMediaType media_type) { - return media_type == AUDIO_EVENT ? kAudioPacketRetransmitted : - kVideoPacketRetransmitted; -} - bool IsReceiverEvent(CastLoggingEvent event) { - return event == kAudioFrameDecoded - || event == kVideoFrameDecoded - || event == kAudioPlayoutDelay - || event == kVideoRenderDelay - || event == kAudioAckSent - || event == kVideoAckSent - || event == kAudioPacketReceived - || event == kVideoPacketReceived - || event == kDuplicateAudioPacketReceived - || event == kDuplicateVideoPacketReceived; + return event == FRAME_DECODED + || event == FRAME_PLAYOUT + || event == FRAME_ACK_SENT + || event == PACKET_RECEIVED; } } // namespace @@ -92,7 +54,7 @@ void StatsEventSubscriber::OnReceiveFrameEvent(const FrameEvent& frame_event) { DCHECK(thread_checker_.CalledOnValidThread()); CastLoggingEvent type = frame_event.type; - if (GetEventMediaType(type) != event_media_type_) + if (frame_event.media_type != event_media_type_) return; FrameStatsMap::iterator it = frame_stats_.find(type); @@ -108,9 +70,9 @@ void StatsEventSubscriber::OnReceiveFrameEvent(const FrameEvent& frame_event) { it->second.sum_delay += frame_event.delay_delta; } - if (type == GetCapturedEvent(event_media_type_)) { + if (type == FRAME_CAPTURE_BEGIN) { RecordFrameCapturedTime(frame_event); - } else if (type == GetPlayoutEvent(event_media_type_)) { + } else if (type == FRAME_PLAYOUT) { RecordE2ELatency(frame_event); } @@ -123,7 +85,7 @@ void StatsEventSubscriber::OnReceivePacketEvent( DCHECK(thread_checker_.CalledOnValidThread()); CastLoggingEvent type = packet_event.type; - if (GetEventMediaType(type) != event_media_type_) + if (packet_event.media_type != event_media_type_) return; PacketStatsMap::iterator it = packet_stats_.find(type); @@ -137,10 +99,10 @@ void StatsEventSubscriber::OnReceivePacketEvent( it->second.sum_size += packet_event.size; } - if (type == GetPacketSentEvent(event_media_type_) || - type == GetPacketReceivedEvent(event_media_type_)) { + if (type == PACKET_SENT_TO_NETWORK || + type == PACKET_RECEIVED) { RecordNetworkLatency(packet_event); - } else if (type == GetPacketRetransmittedEvent(event_media_type_)) { + } else if (type == PACKET_RETRANSMITTED) { // We only measure network latency using packets that doesn't have to be // retransmitted as there is precisely one sent-receive timestamp pairs. ErasePacketSentTime(packet_event); @@ -210,19 +172,19 @@ void StatsEventSubscriber::GetStatsInternal(StatsMap* stats_map) const { base::TimeTicks end_time = clock_->NowTicks(); PopulateFpsStat( - end_time, GetCapturedEvent(event_media_type_), CAPTURE_FPS, stats_map); + end_time, FRAME_CAPTURE_BEGIN, CAPTURE_FPS, stats_map); PopulateFpsStat( - end_time, GetEncodedEvent(event_media_type_), ENCODE_FPS, stats_map); + end_time, FRAME_ENCODED, ENCODE_FPS, stats_map); PopulateFpsStat( - end_time, GetDecodedEvent(event_media_type_), DECODE_FPS, stats_map); + end_time, FRAME_DECODED, DECODE_FPS, stats_map); PopulatePlayoutDelayStat(stats_map); PopulateFrameBitrateStat(end_time, stats_map); PopulatePacketBitrateStat(end_time, - GetPacketSentEvent(event_media_type_), + PACKET_SENT_TO_NETWORK, TRANSMISSION_KBPS, stats_map); PopulatePacketBitrateStat(end_time, - GetPacketRetransmittedEvent(event_media_type_), + PACKET_RETRANSMITTED, RETRANSMISSION_KBPS, stats_map); PopulatePacketLossPercentageStat(stats_map); @@ -324,13 +286,13 @@ void StatsEventSubscriber::RecordNetworkLatency( bool match = false; base::TimeTicks packet_sent_time; base::TimeTicks packet_received_time; - if (recorded_type == GetPacketSentEvent(event_media_type_) && - packet_event.type == GetPacketReceivedEvent(event_media_type_)) { + if (recorded_type == PACKET_SENT_TO_NETWORK && + packet_event.type == PACKET_RECEIVED) { packet_sent_time = value.first; packet_received_time = packet_event.timestamp; match = true; - } else if (recorded_type == GetPacketReceivedEvent(event_media_type_) && - packet_event.type == GetPacketSentEvent(event_media_type_)) { + } else if (recorded_type == PACKET_RECEIVED && + packet_event.type == PACKET_SENT_TO_NETWORK) { packet_sent_time = packet_event.timestamp; packet_received_time = value.first; match = true; @@ -362,8 +324,7 @@ void StatsEventSubscriber::PopulateFpsStat(base::TimeTicks end_time, } void StatsEventSubscriber::PopulatePlayoutDelayStat(StatsMap* stats_map) const { - CastLoggingEvent event = GetPlayoutEvent(event_media_type_); - FrameStatsMap::const_iterator it = frame_stats_.find(event); + FrameStatsMap::const_iterator it = frame_stats_.find(FRAME_PLAYOUT); if (it != frame_stats_.end()) { double avg_delay_ms = 0.0; base::TimeDelta sum_delay = it->second.sum_delay; @@ -376,8 +337,7 @@ void StatsEventSubscriber::PopulatePlayoutDelayStat(StatsMap* stats_map) const { void StatsEventSubscriber::PopulateFrameBitrateStat(base::TimeTicks end_time, StatsMap* stats_map) const { - CastLoggingEvent event = GetEncodedEvent(event_media_type_); - FrameStatsMap::const_iterator it = frame_stats_.find(event); + FrameStatsMap::const_iterator it = frame_stats_.find(FRAME_ENCODED); if (it != frame_stats_.end()) { double kbps = 0.0; base::TimeDelta duration = end_time - start_time_; @@ -412,15 +372,12 @@ void StatsEventSubscriber::PopulatePacketLossPercentageStat( // (re)transmission was lost. // This means the percentage of packet loss is // (# of retransmit events) / (# of transmit + retransmit events). - CastLoggingEvent packet_sent_event = GetPacketSentEvent(event_media_type_); - CastLoggingEvent packet_retransmitted_event = - GetPacketRetransmittedEvent(event_media_type_); PacketStatsMap::const_iterator sent_it = - packet_stats_.find(packet_sent_event); + packet_stats_.find(PACKET_SENT_TO_NETWORK); if (sent_it == packet_stats_.end()) return; PacketStatsMap::const_iterator retransmitted_it = - packet_stats_.find(packet_retransmitted_event); + packet_stats_.find(PACKET_RETRANSMITTED); int sent_count = sent_it->second.event_counter; int retransmitted_count = 0; if (retransmitted_it != packet_stats_.end()) diff --git a/media/cast/logging/stats_event_subscriber.h b/media/cast/logging/stats_event_subscriber.h index 4e198da..173378a 100644 --- a/media/cast/logging/stats_event_subscriber.h +++ b/media/cast/logging/stats_event_subscriber.h @@ -83,7 +83,7 @@ class StatsEventSubscriber : public RawEventSubscriber { DECODE_FPS, // Average encode duration in milliseconds. // TODO(imcheng): This stat is not populated yet because we do not have - // the time when encode started. Record it in kVideoFrameEncoded event. + // the time when encode started. Record it in FRAME_ENCODED event. AVG_ENCODE_TIME_MS, // Average playout delay in milliseconds, with target delay already // accounted for. Ideally, every frame should have a playout delay of 0. diff --git a/media/cast/logging/stats_event_subscriber_unittest.cc b/media/cast/logging/stats_event_subscriber_unittest.cc index 90602d5..33faa02 100644 --- a/media/cast/logging/stats_event_subscriber_unittest.cc +++ b/media/cast/logging/stats_event_subscriber_unittest.cc @@ -74,7 +74,8 @@ TEST_F(StatsEventSubscriberTest, Capture) { base::TimeTicks start_time = sender_clock_->NowTicks(); for (int i = 0; i < num_frames; i++) { cast_environment_->Logging()->InsertFrameEvent(sender_clock_->NowTicks(), - kVideoFrameCaptureBegin, + FRAME_CAPTURE_BEGIN, + VIDEO_EVENT, rtp_timestamp, frame_id); @@ -111,7 +112,7 @@ TEST_F(StatsEventSubscriberTest, Encode) { total_size += size; cast_environment_->Logging()->InsertEncodedFrameEvent( sender_clock_->NowTicks(), - kVideoFrameEncoded, + FRAME_ENCODED, VIDEO_EVENT, rtp_timestamp, frame_id, size, @@ -153,7 +154,7 @@ TEST_F(StatsEventSubscriberTest, Decode) { base::TimeTicks start_time = sender_clock_->NowTicks(); for (int i = 0; i < num_frames; i++) { cast_environment_->Logging()->InsertFrameEvent(receiver_clock_.NowTicks(), - kVideoFrameDecoded, + FRAME_DECODED, VIDEO_EVENT, rtp_timestamp, frame_id); @@ -190,7 +191,8 @@ TEST_F(StatsEventSubscriberTest, PlayoutDelay) { total_delay_ms += delay_ms; cast_environment_->Logging()->InsertFrameEventWithDelay( receiver_clock_.NowTicks(), - kVideoRenderDelay, + FRAME_PLAYOUT, + VIDEO_EVENT, rtp_timestamp, frame_id, delay); @@ -220,7 +222,8 @@ TEST_F(StatsEventSubscriberTest, E2ELatency) { base::TimeDelta total_latency; for (int i = 0; i < num_frames; i++) { cast_environment_->Logging()->InsertFrameEvent(sender_clock_->NowTicks(), - kVideoFrameCaptureBegin, + FRAME_CAPTURE_BEGIN, + VIDEO_EVENT, rtp_timestamp, frame_id); @@ -234,7 +237,8 @@ TEST_F(StatsEventSubscriberTest, E2ELatency) { cast_environment_->Logging()->InsertFrameEventWithDelay( receiver_clock_.NowTicks(), - kVideoRenderDelay, + FRAME_PLAYOUT, + VIDEO_EVENT, rtp_timestamp, frame_id, delay); @@ -274,7 +278,8 @@ TEST_F(StatsEventSubscriberTest, Packets) { total_size += size; cast_environment_->Logging()->InsertPacketEvent(sender_clock_->NowTicks(), - kVideoPacketSentToNetwork, + PACKET_SENT_TO_NETWORK, + VIDEO_EVENT, rtp_timestamp, 0, i, @@ -299,7 +304,8 @@ TEST_F(StatsEventSubscriberTest, Packets) { if (i % 2 == 0) { cast_environment_->Logging()->InsertPacketEvent( receiver_clock_.NowTicks(), - kVideoPacketRetransmitted, + PACKET_RETRANSMITTED, + VIDEO_EVENT, rtp_timestamp, 0, i, @@ -315,7 +321,8 @@ TEST_F(StatsEventSubscriberTest, Packets) { if (i % 4 == 0) { cast_environment_->Logging()->InsertPacketEvent( receiver_clock_.NowTicks(), - kVideoPacketRetransmitted, + PACKET_RETRANSMITTED, + VIDEO_EVENT, rtp_timestamp, 0, i, @@ -331,7 +338,8 @@ TEST_F(StatsEventSubscriberTest, Packets) { if (i % 8 == 0) { cast_environment_->Logging()->InsertPacketEvent( receiver_clock_.NowTicks(), - kVideoPacketRetransmitted, + PACKET_RETRANSMITTED, + VIDEO_EVENT, rtp_timestamp, 0, i, @@ -343,7 +351,8 @@ TEST_F(StatsEventSubscriberTest, Packets) { } cast_environment_->Logging()->InsertPacketEvent(received_time, - kVideoPacketReceived, + PACKET_RECEIVED, + VIDEO_EVENT, rtp_timestamp, 0, i, |