Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: media/cast/rtp_receiver/rtp_receiver.cc

Issue 250363002: [Cast] Clean-up RtpCastHeader and RtpParser, removing the last WebRTC dependency. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed hubbe's comment. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/cast/rtp_receiver/rtp_receiver.h ('k') | media/cast/rtp_receiver/rtp_receiver_defines.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/cast/rtp_receiver/rtp_receiver.h" 5 #include "media/cast/rtp_receiver/rtp_receiver.h"
6 6
7 #include "base/big_endian.h" 7 #include "base/big_endian.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "media/cast/rtp_receiver/receiver_stats.h" 9 #include "media/cast/rtp_receiver/receiver_stats.h"
10 #include "media/cast/rtp_receiver/rtp_parser/rtp_parser.h" 10 #include "media/cast/rtp_receiver/rtp_parser/rtp_parser.h"
11 #include "media/cast/rtp_receiver/rtp_receiver_defines.h" 11 #include "media/cast/rtp_receiver/rtp_receiver_defines.h"
12 12
13 namespace media { 13 namespace media {
14 namespace cast { 14 namespace cast {
15 15
16 namespace {
17
18 static RtpParserConfig GetRtpParserConfig(
19 const AudioReceiverConfig* audio_config,
20 const VideoReceiverConfig* video_config) {
21 RtpParserConfig config;
22 DCHECK(audio_config || video_config) << "Invalid argument";
23 if (audio_config) {
24 config.ssrc = audio_config->incoming_ssrc;
25 config.payload_type = audio_config->rtp_payload_type;
26 config.audio_codec = audio_config->codec;
27 config.audio_channels = audio_config->channels;
28 } else {
29 config.ssrc = video_config->incoming_ssrc;
30 config.payload_type = video_config->rtp_payload_type;
31 config.video_codec = video_config->codec;
32 }
33 return config;
34 }
35
36 } // namespace
37
38 RtpReceiver::RtpReceiver(base::TickClock* clock, 16 RtpReceiver::RtpReceiver(base::TickClock* clock,
39 const AudioReceiverConfig* audio_config, 17 const AudioReceiverConfig* audio_config,
40 const VideoReceiverConfig* video_config) : 18 const VideoReceiverConfig* video_config) :
41 RtpParser(GetRtpParserConfig(audio_config, 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)),
42 stats_(clock) { 23 stats_(clock) {
24 DCHECK(audio_config || video_config);
43 } 25 }
44 26
45 RtpReceiver::~RtpReceiver() {} 27 RtpReceiver::~RtpReceiver() {}
46 28
47 // static 29 // static
48 uint32 RtpReceiver::GetSsrcOfSender(const uint8* rtcp_buffer, size_t length) { 30 uint32 RtpReceiver::GetSsrcOfSender(const uint8* rtcp_buffer, size_t length) {
49 DCHECK_GE(length, kMinLengthOfRtp) << "Invalid RTP packet"; 31 DCHECK_GE(length, kMinLengthOfRtp) << "Invalid RTP packet";
50 uint32 ssrc_of_sender; 32 uint32 ssrc_of_sender;
51 base::BigEndianReader big_endian_reader( 33 base::BigEndianReader big_endian_reader(
52 reinterpret_cast<const char*>(rtcp_buffer), length); 34 reinterpret_cast<const char*>(rtcp_buffer), length);
53 big_endian_reader.Skip(8); // Skip header 35 big_endian_reader.Skip(8); // Skip header
54 big_endian_reader.ReadU32(&ssrc_of_sender); 36 big_endian_reader.ReadU32(&ssrc_of_sender);
55 return ssrc_of_sender; 37 return ssrc_of_sender;
56 } 38 }
57 39
58 bool RtpReceiver::ReceivedPacket(const uint8* packet, size_t length) { 40 bool RtpReceiver::ReceivedPacket(const uint8* packet, size_t length) {
59 RtpCastHeader rtp_header; 41 RtpCastHeader rtp_header;
60 if (!ParsePacket(packet, length, &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)) {
61 return false; 46 return false;
47 }
62 48
49 OnReceivedPayloadData(payload_data, payload_size, rtp_header);
63 stats_.UpdateStatistics(rtp_header); 50 stats_.UpdateStatistics(rtp_header);
64 return true; 51 return true;
65 } 52 }
66 53
67 } // namespace cast 54 } // namespace cast
68 } // namespace media 55 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/rtp_receiver/rtp_receiver.h ('k') | media/cast/rtp_receiver/rtp_receiver_defines.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698