1116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Copyright 2014 The Chromium Authors. All rights reserved. 25d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// found in the LICENSE file. 45d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Utility parser for rtp packetizer unittests 6116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#ifndef MEDIA_CAST_NET_RTP_RTP_HEADER_PARSER_H_ 7116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#define MEDIA_CAST_NET_RTP_RTP_HEADER_PARSER_H_ 85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/basictypes.h" 10116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "media/cast/net/cast_transport_defines.h" 115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace media { 135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace cast { 145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 155c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu// TODO(miu): Kill this and use RtpCastHeader instead. 165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)struct RtpCastTestHeader { 175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) RtpCastTestHeader(); 185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ~RtpCastTestHeader(); 195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Cast specific. 205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool is_key_frame; 215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint32 frame_id; 225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint16 packet_id; 235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint16 max_packet_id; 245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool is_reference; // Set to true if the previous frame is not available, 255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // and the reference frame id is available. 265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint32 reference_frame_id; 275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Rtp Generic. 295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool marker; 305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint16 sequence_number; 315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint32 rtp_timestamp; 325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint32 ssrc; 335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int payload_type; 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint8 num_csrcs; 355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint8 audio_num_energy; 365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int header_length; 375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 395c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu// TODO(miu): Kill this and use RtpParser instead. 405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class RtpHeaderParser { 415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public: 425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) RtpHeaderParser(const uint8* rtpData, size_t rtpDataLength); 435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ~RtpHeaderParser(); 445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool Parse(RtpCastTestHeader* parsed_packet) const; 465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) private: 485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool ParseCommon(RtpCastTestHeader* parsed_packet) const; 495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool ParseCast(RtpCastTestHeader* parsed_packet) const; 505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const uint8* const rtp_data_begin_; 515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) size_t length_; 525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 53116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch mutable FrameIdWrapHelper frame_id_wrap_helper_; 54116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch mutable FrameIdWrapHelper reference_frame_id_wrap_helper_; 555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(RtpHeaderParser); 575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} // namespace cast 605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} // namespace media 615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 62116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#endif // MEDIA_CAST_NET_RTP_RTP_HEADER_PARSER_H_ 63