diff options
24 files changed, 107 insertions, 278 deletions
diff --git a/media/cast/BUILD.gn b/media/cast/BUILD.gn index 188cfca..6b87e13 100644 --- a/media/cast/BUILD.gn +++ b/media/cast/BUILD.gn @@ -87,12 +87,12 @@ source_set("net") { "net/rtp/packet_storage.h", "net/rtp/receiver_stats.cc", "net/rtp/receiver_stats.h", + "net/rtp/rtp_defines.cc", + "net/rtp/rtp_defines.h", "net/rtp/rtp_packetizer.cc", "net/rtp/rtp_packetizer.h", "net/rtp/rtp_parser.cc", "net/rtp/rtp_parser.h", - "net/rtp/rtp_receiver_defines.cc", - "net/rtp/rtp_receiver_defines.h", "net/rtp/rtp_sender.cc", "net/rtp/rtp_sender.h", "net/udp_transport.cc", @@ -310,12 +310,9 @@ test("cast_unittests") { "net/rtp/mock_rtp_payload_feedback.h", "net/rtp/packet_storage_unittest.cc", "net/rtp/receiver_stats_unittest.cc", - "net/rtp/rtp_header_parser.cc", - "net/rtp/rtp_header_parser.h", "net/rtp/rtp_packet_builder.cc", "net/rtp/rtp_packetizer_unittest.cc", "net/rtp/rtp_parser_unittest.cc", - "net/rtp/rtp_receiver_defines.h", "net/udp_transport_unittest.cc", "receiver/audio_decoder_unittest.cc", "receiver/frame_receiver_unittest.cc", diff --git a/media/cast/cast.gyp b/media/cast/cast.gyp index b2acc85..3e8310d 100644 --- a/media/cast/cast.gyp +++ b/media/cast/cast.gyp @@ -107,8 +107,6 @@ 'net/rtp/framer.h', 'net/rtp/receiver_stats.cc', 'net/rtp/receiver_stats.h', - 'net/rtp/rtp_receiver_defines.cc', - 'net/rtp/rtp_receiver_defines.h', 'receiver/audio_decoder.cc', 'receiver/audio_decoder.h', 'receiver/cast_receiver_impl.cc', @@ -248,6 +246,8 @@ 'net/rtcp/rtcp_utility.h', 'net/rtp/packet_storage.cc', 'net/rtp/packet_storage.h', + 'net/rtp/rtp_defines.cc', + 'net/rtp/rtp_defines.h', 'net/rtp/rtp_packetizer.cc', 'net/rtp/rtp_packetizer.h', 'net/rtp/rtp_parser.cc', diff --git a/media/cast/cast_testing.gypi b/media/cast/cast_testing.gypi index b13bb5b..116727e 100644 --- a/media/cast/cast_testing.gypi +++ b/media/cast/cast_testing.gypi @@ -103,12 +103,11 @@ 'net/rtp/mock_rtp_payload_feedback.h', 'net/rtp/packet_storage_unittest.cc', 'net/rtp/receiver_stats_unittest.cc', - 'net/rtp/rtp_header_parser.cc', - 'net/rtp/rtp_header_parser.h', 'net/rtp/rtp_packet_builder.cc', 'net/rtp/rtp_packetizer_unittest.cc', + 'net/rtp/rtp_parser.cc', + 'net/rtp/rtp_parser.h', 'net/rtp/rtp_parser_unittest.cc', - 'net/rtp/rtp_receiver_defines.h', 'net/udp_transport_unittest.cc', 'receiver/audio_decoder_unittest.cc', 'receiver/frame_receiver_unittest.cc', diff --git a/media/cast/net/rtp/cast_message_builder.h b/media/cast/net/rtp/cast_message_builder.h index 58d8e9a..ab9b72f 100644 --- a/media/cast/net/rtp/cast_message_builder.h +++ b/media/cast/net/rtp/cast_message_builder.h @@ -4,14 +4,14 @@ // Handles NACK list and manages ACK. -#ifndef MEDIA_CAST_FRAMER_CAST_MESSAGE_BUILDER_H_ -#define MEDIA_CAST_FRAMER_CAST_MESSAGE_BUILDER_H_ +#ifndef MEDIA_CAST_NET_RTP_CAST_MESSAGE_BUILDER_H_ +#define MEDIA_CAST_NET_RTP_CAST_MESSAGE_BUILDER_H_ #include <deque> #include <map> #include "media/cast/net/rtcp/rtcp.h" -#include "media/cast/net/rtp/rtp_receiver_defines.h" +#include "media/cast/net/rtp/rtp_defines.h" namespace media { namespace cast { @@ -66,4 +66,4 @@ class CastMessageBuilder { } // namespace cast } // namespace media -#endif // MEDIA_CAST_FRAMER_CAST_MESSAGE_BUILDER_H_ +#endif // MEDIA_CAST_NET_RTP_CAST_MESSAGE_BUILDER_H_ diff --git a/media/cast/net/rtp/cast_message_builder_unittest.cc b/media/cast/net/rtp/cast_message_builder_unittest.cc index bae827a..166834e 100644 --- a/media/cast/net/rtp/cast_message_builder_unittest.cc +++ b/media/cast/net/rtp/cast_message_builder_unittest.cc @@ -9,7 +9,7 @@ #include "media/cast/net/rtcp/rtcp.h" #include "media/cast/net/rtp/cast_message_builder.h" #include "media/cast/net/rtp/framer.h" -#include "media/cast/net/rtp/rtp_receiver_defines.h" +#include "media/cast/net/rtp/rtp_defines.h" #include "testing/gtest/include/gtest/gtest.h" namespace media { @@ -139,6 +139,7 @@ class CastMessageBuilderTest : public ::testing::Test { RtpCastHeader rtp_header_; base::SimpleTestTickClock testing_clock_; + private: DISALLOW_COPY_AND_ASSIGN(CastMessageBuilderTest); }; diff --git a/media/cast/net/rtp/frame_buffer.h b/media/cast/net/rtp/frame_buffer.h index 1089433..b7cd320 100644 --- a/media/cast/net/rtp/frame_buffer.h +++ b/media/cast/net/rtp/frame_buffer.h @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef MEDIA_CAST_FRAMER_FRAME_BUFFER -#define MEDIA_CAST_FRAMER_FRAME_BUFFER +#ifndef MEDIA_CAST_NET_RTP_FRAME_BUFFER_H_ +#define MEDIA_CAST_NET_RTP_FRAME_BUFFER_H_ #include <map> #include <vector> #include "media/cast/cast_config.h" -#include "media/cast/net/rtp/rtp_receiver_defines.h" +#include "media/cast/net/rtp/rtp_defines.h" namespace media { namespace cast { @@ -55,4 +55,4 @@ class FrameBuffer { } // namespace cast } // namespace media -#endif // MEDIA_CAST_FRAMER_FRAME_BUFFER +#endif // MEDIA_CAST_NET_RTP_FRAME_BUFFER_H_ diff --git a/media/cast/net/rtp/framer.h b/media/cast/net/rtp/framer.h index 95c1a0e..e39bafe 100644 --- a/media/cast/net/rtp/framer.h +++ b/media/cast/net/rtp/framer.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef MEDIA_CAST_FRAMER_FRAMER_H_ -#define MEDIA_CAST_FRAMER_FRAMER_H_ +#ifndef MEDIA_CAST_NET_RTP_FRAMER_H_ +#define MEDIA_CAST_NET_RTP_FRAMER_H_ #include <map> @@ -15,7 +15,7 @@ #include "media/cast/net/rtcp/rtcp.h" #include "media/cast/net/rtp/cast_message_builder.h" #include "media/cast/net/rtp/frame_buffer.h" -#include "media/cast/net/rtp/rtp_receiver_defines.h" +#include "media/cast/net/rtp/rtp_defines.h" namespace media { namespace cast { @@ -93,4 +93,4 @@ class Framer { } // namespace cast } // namespace media -#endif // MEDIA_CAST_FRAMER_FRAMER_H_ +#endif // MEDIA_CAST_NET_RTP_FRAMER_H_ diff --git a/media/cast/net/rtp/mock_rtp_feedback.h b/media/cast/net/rtp/mock_rtp_feedback.h index 44624ff..9542081 100644 --- a/media/cast/net/rtp/mock_rtp_feedback.h +++ b/media/cast/net/rtp/mock_rtp_feedback.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef MEDIA_CAST_RTP_INCLUDE_MOCK_RTP_FEEDBACK_H_ -#define MEDIA_CAST_RTP_INCLUDE_MOCK_RTP_FEEDBACK_H_ +#ifndef MEDIA_CAST_NET_RTP_MOCK_RTP_FEEDBACK_H_ +#define MEDIA_CAST_NET_RTP_MOCK_RTP_FEEDBACK_H_ #include "media/cast/net/rtp/rtp_parser/rtp_feedback.h" #include "testing/gmock/include/gmock/gmock.h" @@ -32,4 +32,4 @@ class MockRtpFeedback : public RtpFeedback { } // namespace cast } // namespace media -#endif // MEDIA_CAST_RTP_INCLUDE_MOCK_RTP_FEEDBACK_H_ +#endif // MEDIA_CAST_NET_RTP_MOCK_RTP_FEEDBACK_H_ diff --git a/media/cast/net/rtp/mock_rtp_payload_feedback.h b/media/cast/net/rtp/mock_rtp_payload_feedback.h index f46d318..ab329d1 100644 --- a/media/cast/net/rtp/mock_rtp_payload_feedback.h +++ b/media/cast/net/rtp/mock_rtp_payload_feedback.h @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef MEDIA_CAST_RTP_COMMON_MOCK_RTP_PAYLOAD_FEEDBACK_H_ -#define MEDIA_CAST_RTP_COMMON_MOCK_RTP_PAYLOAD_FEEDBACK_H_ +#ifndef MEDIA_CAST_NET_RTP_MOCK_RTP_PAYLOAD_FEEDBACK_H_ +#define MEDIA_CAST_NET_RTP_MOCK_RTP_PAYLOAD_FEEDBACK_H_ -#include "media/cast/net/rtp/rtp_receiver_defines.h" +#include "media/cast/net/rtp/rtp_defines.h" #include "testing/gmock/include/gmock/gmock.h" namespace media { @@ -22,4 +22,4 @@ class MockRtpPayloadFeedback : public RtpPayloadFeedback { } // namespace cast } // namespace media -#endif // MEDIA_CAST_RTP_COMMON_MOCK_RTP_PAYLOAD_FEEDBACK_H_ +#endif // MEDIA_CAST_NET_RTP_MOCK_RTP_PAYLOAD_FEEDBACK_H_ diff --git a/media/cast/net/rtp/receiver_stats.cc b/media/cast/net/rtp/receiver_stats.cc index 2dbdbcb..c9b386d 100644 --- a/media/cast/net/rtp/receiver_stats.cc +++ b/media/cast/net/rtp/receiver_stats.cc @@ -5,7 +5,7 @@ #include "media/cast/net/rtp/receiver_stats.h" #include "base/logging.h" -#include "media/cast/net/rtp/rtp_receiver_defines.h" +#include "media/cast/net/rtp/rtp_defines.h" namespace media { namespace cast { diff --git a/media/cast/net/rtp/receiver_stats.h b/media/cast/net/rtp/receiver_stats.h index 9cdda97..5ffbb5f 100644 --- a/media/cast/net/rtp/receiver_stats.h +++ b/media/cast/net/rtp/receiver_stats.h @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef MEDIA_CAST_RTP_RECEIVER_RECEIVER_STATS_H_ -#define MEDIA_CAST_RTP_RECEIVER_RECEIVER_STATS_H_ +#ifndef MEDIA_CAST_NET_RTP_RECEIVER_STATS_H_ +#define MEDIA_CAST_NET_RTP_RECEIVER_STATS_H_ #include "base/time/tick_clock.h" #include "base/time/time.h" #include "media/cast/net/rtcp/rtcp.h" -#include "media/cast/net/rtp/rtp_receiver_defines.h" +#include "media/cast/net/rtp/rtp_defines.h" namespace media { namespace cast { @@ -43,4 +43,4 @@ class ReceiverStats { } // namespace cast } // namespace media -#endif // MEDIA_CAST_RTP_RECEIVER_RECEIVER_STATS_H_ +#endif // MEDIA_CAST_NET_RTP_RECEIVER_STATS_H_ diff --git a/media/cast/net/rtp/receiver_stats_unittest.cc b/media/cast/net/rtp/receiver_stats_unittest.cc index 4bde4a3..9784b90 100644 --- a/media/cast/net/rtp/receiver_stats_unittest.cc +++ b/media/cast/net/rtp/receiver_stats_unittest.cc @@ -9,7 +9,7 @@ #include "base/test/simple_test_tick_clock.h" #include "base/time/time.h" #include "media/cast/net/rtp/receiver_stats.h" -#include "media/cast/net/rtp/rtp_receiver_defines.h" +#include "media/cast/net/rtp/rtp_defines.h" namespace media { namespace cast { @@ -45,6 +45,7 @@ class ReceiverStatsTest : public ::testing::Test { base::TimeTicks start_time_; base::TimeDelta delta_increments_; + private: DISALLOW_COPY_AND_ASSIGN(ReceiverStatsTest); }; diff --git a/media/cast/net/rtp/rtp_receiver_defines.cc b/media/cast/net/rtp/rtp_defines.cc index 325b305..3ce9c81 100644 --- a/media/cast/net/rtp/rtp_receiver_defines.cc +++ b/media/cast/net/rtp/rtp_defines.cc @@ -1,8 +1,8 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. +// Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "media/cast/net/rtp/rtp_receiver_defines.h" +#include "media/cast/net/rtp/rtp_defines.h" namespace media { namespace cast { diff --git a/media/cast/net/rtp/rtp_defines.h b/media/cast/net/rtp/rtp_defines.h index 56df66d..fd71638 100644 --- a/media/cast/net/rtp/rtp_defines.h +++ b/media/cast/net/rtp/rtp_defines.h @@ -2,19 +2,60 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#ifndef MEDIA_CAST_NET_RTP_RTP_DEFINES_H_ +#define MEDIA_CAST_NET_RTP_RTP_DEFINES_H_ + +#include "base/basictypes.h" +#include "media/cast/net/rtcp/rtcp_defines.h" + namespace media { namespace cast { static const uint16 kRtpHeaderLength = 12; static const uint16 kCastHeaderLength = 7; + +// RTP Header static const uint8 kRtpExtensionBitMask = 0x10; +static const uint8 kRtpMarkerBitMask = 0x80; +static const uint8 kRtpNumCsrcsMask = 0x0f; + +// Cast Header static const uint8 kCastKeyFrameBitMask = 0x80; static const uint8 kCastReferenceFrameIdBitMask = 0x40; -static const uint8 kRtpMarkerBitMask = 0x80; static const uint8 kCastExtensionCountmask = 0x3f; // Cast RTP extensions. static const uint8 kCastRtpExtensionAdaptiveLatency = 1; +struct RtpCastHeader { + RtpCastHeader(); + // Elements from RTP packet header. + bool marker; + uint8 payload_type; + uint16 sequence_number; + uint32 rtp_timestamp; + uint32 sender_ssrc; + uint8 num_csrcs; + + // Elements from Cast header (at beginning of RTP payload). + bool is_key_frame; + bool is_reference; + uint32 frame_id; + uint16 packet_id; + uint16 max_packet_id; + uint32 reference_frame_id; + uint16 new_playout_delay_ms; +}; + +class RtpPayloadFeedback { + public: + virtual void CastFeedback(const RtcpCastMessage& cast_feedback) = 0; + + protected: + virtual ~RtpPayloadFeedback(); +}; + } // namespace cast } // namespace media + +#endif // MEDIA_CAST_NET_RTP_RTP_DEFINES_H_ diff --git a/media/cast/net/rtp/rtp_header_parser.cc b/media/cast/net/rtp/rtp_header_parser.cc deleted file mode 100644 index 2d70f98..0000000 --- a/media/cast/net/rtp/rtp_header_parser.cc +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "media/cast/net/rtp/rtp_header_parser.h" - -#include <cstddef> - -#include "base/big_endian.h" - -namespace media { -namespace cast { - -static const uint8 kCastKeyFrameBitMask = 0x80; -static const uint8 kCastReferenceFrameIdBitMask = 0x40; -static const size_t kRtpCommonHeaderLength = 12; -static const size_t kRtpCastHeaderLength = 12; - -RtpCastTestHeader::RtpCastTestHeader() - : is_key_frame(false), - frame_id(0), - packet_id(0), - max_packet_id(0), - is_reference(false), - reference_frame_id(0), - marker(false), - sequence_number(0), - rtp_timestamp(0), - ssrc(0), - payload_type(0), - num_csrcs(0), - audio_num_energy(0), - header_length(0) {} - -RtpCastTestHeader::~RtpCastTestHeader() {} - -RtpHeaderParser::RtpHeaderParser(const uint8* rtp_data, size_t rtp_data_length) - : rtp_data_begin_(rtp_data), length_(rtp_data_length) {} - -RtpHeaderParser::~RtpHeaderParser() {} - -bool RtpHeaderParser::Parse(RtpCastTestHeader* parsed_packet) const { - if (length_ < kRtpCommonHeaderLength + kRtpCastHeaderLength) - return false; - if (!ParseCommon(parsed_packet)) - return false; - return ParseCast(parsed_packet); -} - -bool RtpHeaderParser::ParseCommon(RtpCastTestHeader* parsed_packet) const { - const uint8 version = rtp_data_begin_[0] >> 6; - if (version != 2) { - return false; - } - - const uint8 num_csrcs = rtp_data_begin_[0] & 0x0f; - const bool marker = ((rtp_data_begin_[1] & 0x80) == 0) ? false : true; - const uint8 payload_type = rtp_data_begin_[1] & 0x7f; - const uint16 sequence_number = (rtp_data_begin_[2] << 8) + rtp_data_begin_[3]; - - const uint8* ptr = &rtp_data_begin_[4]; - - base::BigEndianReader big_endian_reader(reinterpret_cast<const char*>(ptr), - 8); - uint32 rtp_timestamp, ssrc; - big_endian_reader.ReadU32(&rtp_timestamp); - big_endian_reader.ReadU32(&ssrc); - - const uint8 csrc_octs = num_csrcs * 4; - - parsed_packet->marker = marker; - parsed_packet->payload_type = payload_type; - parsed_packet->sequence_number = sequence_number; - parsed_packet->rtp_timestamp = rtp_timestamp; - parsed_packet->ssrc = ssrc; - parsed_packet->num_csrcs = num_csrcs; - - parsed_packet->audio_num_energy = parsed_packet->num_csrcs; - - parsed_packet->header_length = 12 + csrc_octs; - return true; -} - -bool RtpHeaderParser::ParseCast(RtpCastTestHeader* parsed_packet) const { - const uint8* data = rtp_data_begin_ + kRtpCommonHeaderLength; - parsed_packet->is_key_frame = (data[0] & kCastKeyFrameBitMask); - parsed_packet->is_reference = (data[0] & kCastReferenceFrameIdBitMask); - parsed_packet->frame_id = frame_id_wrap_helper_.MapTo32bitsFrameId(data[1]); - - base::BigEndianReader big_endian_reader( - reinterpret_cast<const char*>(data + 2), 8); - big_endian_reader.ReadU16(&parsed_packet->packet_id); - big_endian_reader.ReadU16(&parsed_packet->max_packet_id); - - if (parsed_packet->is_reference) { - parsed_packet->reference_frame_id = - reference_frame_id_wrap_helper_.MapTo32bitsFrameId(data[6]); - } - return true; -} - -} // namespace cast -} // namespace media diff --git a/media/cast/net/rtp/rtp_header_parser.h b/media/cast/net/rtp/rtp_header_parser.h deleted file mode 100644 index fd235c2..0000000 --- a/media/cast/net/rtp/rtp_header_parser.h +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Utility parser for rtp packetizer unittests -#ifndef MEDIA_CAST_NET_RTP_RTP_HEADER_PARSER_H_ -#define MEDIA_CAST_NET_RTP_RTP_HEADER_PARSER_H_ - -#include "base/basictypes.h" -#include "media/cast/net/cast_transport_defines.h" - -namespace media { -namespace cast { - -// TODO(miu): Kill this and use RtpCastHeader instead. -struct RtpCastTestHeader { - RtpCastTestHeader(); - ~RtpCastTestHeader(); - // Cast specific. - bool is_key_frame; - uint32 frame_id; - uint16 packet_id; - uint16 max_packet_id; - bool is_reference; // Set to true if the previous frame is not available, - // and the reference frame id is available. - uint32 reference_frame_id; - - // Rtp Generic. - bool marker; - uint16 sequence_number; - uint32 rtp_timestamp; - uint32 ssrc; - int payload_type; - uint8 num_csrcs; - uint8 audio_num_energy; - int header_length; -}; - -// TODO(miu): Kill this and use RtpParser instead. -class RtpHeaderParser { - public: - RtpHeaderParser(const uint8* rtpData, size_t rtpDataLength); - ~RtpHeaderParser(); - - bool Parse(RtpCastTestHeader* parsed_packet) const; - - private: - bool ParseCommon(RtpCastTestHeader* parsed_packet) const; - bool ParseCast(RtpCastTestHeader* parsed_packet) const; - const uint8* const rtp_data_begin_; - size_t length_; - - mutable FrameIdWrapHelper frame_id_wrap_helper_; - mutable FrameIdWrapHelper reference_frame_id_wrap_helper_; - - DISALLOW_COPY_AND_ASSIGN(RtpHeaderParser); -}; - -} // namespace cast -} // namespace media - -#endif // MEDIA_CAST_NET_RTP_RTP_HEADER_PARSER_H_ diff --git a/media/cast/net/rtp/rtp_packet_builder.cc b/media/cast/net/rtp/rtp_packet_builder.cc index 2f279f4..4501dbf 100644 --- a/media/cast/net/rtp/rtp_packet_builder.cc +++ b/media/cast/net/rtp/rtp_packet_builder.cc @@ -10,10 +10,6 @@ namespace media { namespace cast { -const uint32 kCastRtpHeaderLength = 7; -const uint32 kGenericRtpHeaderLength = 12; -static const uint8 kRtpMarkerBitMask = 0x80; - RtpPacketBuilder::RtpPacketBuilder() : is_key_(false), frame_id_(0), @@ -57,15 +53,14 @@ void RtpPacketBuilder::SetSsrc(uint32 ssrc) { ssrc_ = ssrc; } void RtpPacketBuilder::BuildHeader(uint8* data, uint32 data_length) { BuildCommonHeader(data, data_length); - BuildCastHeader(data + kGenericRtpHeaderLength, - data_length - kGenericRtpHeaderLength); + BuildCastHeader(data + kRtpHeaderLength, data_length - kRtpHeaderLength); } void RtpPacketBuilder::BuildCastHeader(uint8* data, uint32 data_length) { // Build header. - DCHECK_LE(kCastRtpHeaderLength, data_length); + DCHECK_LE(kCastHeaderLength, data_length); // Set the first 7 bytes to 0. - memset(data, 0, kCastRtpHeaderLength); + memset(data, 0, kCastHeaderLength); base::BigEndianWriter big_endian_writer(reinterpret_cast<char*>(data), 56); const bool includes_specific_frame_reference = (is_key_ && (reference_frame_id_ != frame_id_)) || @@ -81,7 +76,7 @@ void RtpPacketBuilder::BuildCastHeader(uint8* data, uint32 data_length) { } void RtpPacketBuilder::BuildCommonHeader(uint8* data, uint32 data_length) { - DCHECK_LE(kGenericRtpHeaderLength, data_length); + DCHECK_LE(kRtpHeaderLength, data_length); base::BigEndianWriter big_endian_writer(reinterpret_cast<char*>(data), 96); big_endian_writer.WriteU8(0x80); big_endian_writer.WriteU8(payload_type_ | (marker_ ? kRtpMarkerBitMask : 0)); diff --git a/media/cast/net/rtp/rtp_packet_builder.h b/media/cast/net/rtp/rtp_packet_builder.h index 3d65797..da8efc9 100644 --- a/media/cast/net/rtp/rtp_packet_builder.h +++ b/media/cast/net/rtp/rtp_packet_builder.h @@ -4,10 +4,10 @@ // Test helper class that builds rtp packets. -#ifndef MEDIA_CAST_RTP_RECEIVER_RTP_PARSER_TEST_RTP_PACKET_BUILDER_H_ -#define MEDIA_CAST_RTP_RECEIVER_RTP_PARSER_TEST_RTP_PACKET_BUILDER_H_ +#ifndef MEDIA_CAST_NET_RTP_RTP_PACKET_BUILDER_H_ +#define MEDIA_CAST_NET_RTP_RTP_PACKET_BUILDER_H_ -#include "media/cast/net/rtp/rtp_receiver_defines.h" +#include "media/cast/net/rtp/rtp_defines.h" namespace media { namespace cast { @@ -49,4 +49,4 @@ class RtpPacketBuilder { } // namespace cast } // namespace media -#endif // MEDIA_CAST_RTP_RECEIVER_RTP_PARSER_TEST_RTP_PACKET_BUILDER_H_ +#endif // MEDIA_CAST_NET_RTP_RTP_PACKET_BUILDER_H_ diff --git a/media/cast/net/rtp/rtp_packetizer_unittest.cc b/media/cast/net/rtp/rtp_packetizer_unittest.cc index 802a9c4..5b76308 100644 --- a/media/cast/net/rtp/rtp_packetizer_unittest.cc +++ b/media/cast/net/rtp/rtp_packetizer_unittest.cc @@ -12,7 +12,7 @@ #include "media/cast/logging/simple_event_subscriber.h" #include "media/cast/net/pacing/paced_sender.h" #include "media/cast/net/rtp/packet_storage.h" -#include "media/cast/net/rtp/rtp_header_parser.h" +#include "media/cast/net/rtp/rtp_parser.h" #include "media/cast/test/fake_single_thread_task_runner.h" #include "testing/gmock/include/gmock/gmock.h" @@ -39,20 +39,20 @@ class TestRtpPacketTransport : public PacketSender { expected_frame_id_(0), expected_rtp_timestamp_(0) {} - void VerifyRtpHeader(const RtpCastTestHeader& rtp_header) { + void VerifyRtpHeader(const RtpCastHeader& rtp_header) { VerifyCommonRtpHeader(rtp_header); VerifyCastRtpHeader(rtp_header); } - void VerifyCommonRtpHeader(const RtpCastTestHeader& rtp_header) { + void VerifyCommonRtpHeader(const RtpCastHeader& rtp_header) { EXPECT_EQ(kPayload, rtp_header.payload_type); EXPECT_EQ(sequence_number_, rtp_header.sequence_number); EXPECT_EQ(expected_rtp_timestamp_, rtp_header.rtp_timestamp); - EXPECT_EQ(config_.ssrc, rtp_header.ssrc); + EXPECT_EQ(config_.ssrc, rtp_header.sender_ssrc); EXPECT_EQ(0, rtp_header.num_csrcs); } - void VerifyCastRtpHeader(const RtpCastTestHeader& rtp_header) { + void VerifyCastRtpHeader(const RtpCastHeader& rtp_header) { EXPECT_FALSE(rtp_header.is_key_frame); EXPECT_EQ(expected_frame_id_, rtp_header.frame_id); EXPECT_EQ(expected_packet_id_, rtp_header.packet_id); @@ -63,9 +63,12 @@ class TestRtpPacketTransport : public PacketSender { bool SendPacket(PacketRef packet, const base::Closure& cb) final { ++packets_sent_; - RtpHeaderParser parser(&packet->data[0], packet->data.size()); - RtpCastTestHeader rtp_header; - parser.Parse(&rtp_header); + RtpParser parser(kSsrc, kPayload); + RtpCastHeader rtp_header; + const uint8* payload_data; + size_t payload_size; + parser.ParsePacket(&packet->data[0], packet->data.size(), &rtp_header, + &payload_data, &payload_size); VerifyRtpHeader(rtp_header); ++sequence_number_; ++expected_packet_id_; @@ -94,6 +97,7 @@ class TestRtpPacketTransport : public PacketSender { uint32 expected_frame_id_; uint32 expected_rtp_timestamp_; + private: DISALLOW_COPY_AND_ASSIGN(TestRtpPacketTransport); }; @@ -140,6 +144,7 @@ class RtpPacketizerTest : public ::testing::Test { scoped_ptr<PacedSender> pacer_; scoped_ptr<RtpPacketizer> rtp_packetizer_; + private: DISALLOW_COPY_AND_ASSIGN(RtpPacketizerTest); }; diff --git a/media/cast/net/rtp/rtp_parser.cc b/media/cast/net/rtp/rtp_parser.cc index bb6c2c0..2674156 100644 --- a/media/cast/net/rtp/rtp_parser.cc +++ b/media/cast/net/rtp/rtp_parser.cc @@ -51,6 +51,7 @@ bool RtpParser::ParsePacket(const uint8* packet, const uint8 version = bits >> 6; if (version != 2) return false; + header->num_csrcs = bits & kRtpNumCsrcsMask; if (bits & kRtpExtensionBitMask) return false; // We lack the implementation to skip over an extension. if (!reader.ReadU8(&bits)) @@ -73,8 +74,7 @@ bool RtpParser::ParsePacket(const uint8* packet, if (!reader.ReadU8(&bits)) return false; header->is_key_frame = !!(bits & kCastKeyFrameBitMask); - const bool includes_specific_frame_reference = - !!(bits & kCastReferenceFrameIdBitMask); + header->is_reference = !!(bits & kCastReferenceFrameIdBitMask); uint8 truncated_frame_id; if (!reader.ReadU8(&truncated_frame_id) || !reader.ReadU16(&header->packet_id) || @@ -85,7 +85,7 @@ bool RtpParser::ParsePacket(const uint8* packet, if (header->max_packet_id < header->packet_id) return false; uint8 truncated_reference_frame_id; - if (!includes_specific_frame_reference) { + if (!header->is_reference) { // By default, a key frame only references itself; and non-key frames // reference their direct predecessor. truncated_reference_frame_id = truncated_frame_id; @@ -107,7 +107,6 @@ bool RtpParser::ParsePacket(const uint8* packet, case kCastRtpExtensionAdaptiveLatency: if (!chunk.ReadU16(&header->new_playout_delay_ms)) return false; - } } diff --git a/media/cast/net/rtp/rtp_parser.h b/media/cast/net/rtp/rtp_parser.h index 821507c..d9e6ab9 100644 --- a/media/cast/net/rtp/rtp_parser.h +++ b/media/cast/net/rtp/rtp_parser.h @@ -6,7 +6,7 @@ #define MEDIA_CAST_NET_RTP_RTP_PARSER_H_ #include "media/cast/net/cast_transport_defines.h" -#include "media/cast/net/rtp/rtp_receiver_defines.h" +#include "media/cast/net/rtp/rtp_defines.h" namespace media { namespace cast { diff --git a/media/cast/net/rtp/rtp_parser_unittest.cc b/media/cast/net/rtp/rtp_parser_unittest.cc index 1eca556..97d0922 100644 --- a/media/cast/net/rtp/rtp_parser_unittest.cc +++ b/media/cast/net/rtp/rtp_parser_unittest.cc @@ -4,9 +4,9 @@ #include "base/memory/scoped_ptr.h" #include "base/rand_util.h" +#include "media/cast/net/rtp/rtp_defines.h" #include "media/cast/net/rtp/rtp_packet_builder.h" #include "media/cast/net/rtp/rtp_parser.h" -#include "media/cast/net/rtp/rtp_receiver_defines.h" #include "testing/gtest/include/gtest/gtest.h" namespace media { diff --git a/media/cast/net/rtp/rtp_receiver_defines.h b/media/cast/net/rtp/rtp_receiver_defines.h deleted file mode 100644 index 23a1849..0000000 --- a/media/cast/net/rtp/rtp_receiver_defines.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef MEDIA_CAST_RTP_RECEIVER_RTP_RECEIVER_DEFINES_H_ -#define MEDIA_CAST_RTP_RECEIVER_RTP_RECEIVER_DEFINES_H_ - -#include "base/basictypes.h" -#include "media/cast/cast_config.h" -#include "media/cast/net/rtcp/rtcp_defines.h" - -namespace media { -namespace cast { - -struct RtpCastHeader { - RtpCastHeader(); - - // Elements from RTP packet header. - bool marker; - uint8 payload_type; - uint16 sequence_number; - uint32 rtp_timestamp; - uint32 sender_ssrc; - - // Elements from Cast header (at beginning of RTP payload). - bool is_key_frame; - uint32 frame_id; - uint16 packet_id; - uint16 max_packet_id; - uint32 reference_frame_id; - - uint16 new_playout_delay_ms; -}; - -class RtpPayloadFeedback { - public: - virtual void CastFeedback(const RtcpCastMessage& cast_feedback) = 0; - - protected: - virtual ~RtpPayloadFeedback(); -}; - -} // namespace cast -} // namespace media - -#endif // MEDIA_CAST_RTP_RECEIVER_RTP_RECEIVER_DEFINES_H_ diff --git a/media/cast/receiver/frame_receiver.h b/media/cast/receiver/frame_receiver.h index f4037dd..96f29f4 100644 --- a/media/cast/receiver/frame_receiver.h +++ b/media/cast/receiver/frame_receiver.h @@ -5,6 +5,8 @@ #ifndef MEDIA_CAST_RECEIVER_FRAME_RECEIVER_H_ #define MEDIA_CAST_RECEIVER_FRAME_RECEIVER_H_ +#include <list> + #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" @@ -18,8 +20,8 @@ #include "media/cast/net/rtcp/rtcp.h" #include "media/cast/net/rtp/framer.h" #include "media/cast/net/rtp/receiver_stats.h" +#include "media/cast/net/rtp/rtp_defines.h" #include "media/cast/net/rtp/rtp_parser.h" -#include "media/cast/net/rtp/rtp_receiver_defines.h" namespace media { namespace cast { |