15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Copyright 2013 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 65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#ifndef MEDIA_CAST_TRANSPORT_RTP_SENDER_RTP_PACKETIZER_TEST_RTP_HEADER_PARSER_H_ 75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define MEDIA_CAST_TRANSPORT_RTP_SENDER_RTP_PACKETIZER_TEST_RTP_HEADER_PARSER_H_ 85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/basictypes.h" 105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "media/cast/transport/cast_transport_defines.h" 115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace media { 135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace cast { 145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace transport { 155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 165c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu// TODO(miu): Kill this and use RtpCastHeader instead. 175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)struct RtpCastTestHeader { 185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) RtpCastTestHeader(); 195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ~RtpCastTestHeader(); 205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Cast specific. 215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool is_key_frame; 225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint32 frame_id; 235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint16 packet_id; 245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint16 max_packet_id; 255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool is_reference; // Set to true if the previous frame is not available, 265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // and the reference frame id is available. 275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint32 reference_frame_id; 285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Rtp Generic. 305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool marker; 315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint16 sequence_number; 325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint32 rtp_timestamp; 335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint32 ssrc; 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int payload_type; 355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint8 num_csrcs; 365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint8 audio_num_energy; 375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int header_length; 385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 405c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu// TODO(miu): Kill this and use RtpParser instead. 415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class RtpHeaderParser { 425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public: 435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) RtpHeaderParser(const uint8* rtpData, size_t rtpDataLength); 445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ~RtpHeaderParser(); 455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool Parse(RtpCastTestHeader* parsed_packet) const; 475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) private: 495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool ParseCommon(RtpCastTestHeader* parsed_packet) const; 505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool ParseCast(RtpCastTestHeader* parsed_packet) const; 515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const uint8* const rtp_data_begin_; 525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) size_t length_; 535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) mutable transport::FrameIdWrapHelper frame_id_wrap_helper_; 555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) mutable transport::FrameIdWrapHelper reference_frame_id_wrap_helper_; 565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(RtpHeaderParser); 585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} // namespace transport 615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} // namespace cast 625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} // namespace media 635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#endif // MEDIA_CAST_TRANSPORT_RTP_SENDER_RTP_PACKETIZER_TEST_RTP_HEADER_PARSER_H_ 65