linux_aura: Disable the plugin install infobar.
[chromium-blink-merge.git] / media / cast / rtp_receiver / rtp_receiver.cc
blobf7ff50b3752d5dab9f3fdfd6770e48df9b172f25
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "media/cast/rtp_receiver/rtp_receiver.h"
7 #include "base/big_endian.h"
8 #include "base/logging.h"
9 #include "media/cast/rtp_receiver/receiver_stats.h"
10 #include "media/cast/rtp_receiver/rtp_parser/rtp_parser.h"
11 #include "media/cast/rtp_receiver/rtp_receiver_defines.h"
13 namespace media {
14 namespace cast {
16 RtpReceiver::RtpReceiver(base::TickClock* clock,
17 const FrameReceiverConfig* audio_config,
18 const FrameReceiverConfig* video_config) :
19 packet_parser_(audio_config ? audio_config->incoming_ssrc :
20 (video_config ? video_config->incoming_ssrc : 0),
21 audio_config ? audio_config->rtp_payload_type :
22 (video_config ? video_config->rtp_payload_type : 0)),
23 stats_(clock) {
24 DCHECK(audio_config || video_config);
27 RtpReceiver::~RtpReceiver() {}
29 // static
30 uint32 RtpReceiver::GetSsrcOfSender(const uint8* rtcp_buffer, size_t length) {
31 DCHECK_GE(length, kMinLengthOfRtp) << "Invalid RTP packet";
32 uint32 ssrc_of_sender;
33 base::BigEndianReader big_endian_reader(
34 reinterpret_cast<const char*>(rtcp_buffer), length);
35 big_endian_reader.Skip(8); // Skip header
36 big_endian_reader.ReadU32(&ssrc_of_sender);
37 return ssrc_of_sender;
40 bool RtpReceiver::ReceivedPacket(const uint8* packet, size_t length) {
41 RtpCastHeader rtp_header;
42 const uint8* payload_data;
43 size_t payload_size;
44 if (!packet_parser_.ParsePacket(
45 packet, length, &rtp_header, &payload_data, &payload_size)) {
46 return false;
49 OnReceivedPayloadData(payload_data, payload_size, rtp_header);
50 stats_.UpdateStatistics(rtp_header);
51 return true;
54 } // namespace cast
55 } // namespace media