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

Side by Side Diff: webrtc/media/base/rtpdataengine.cc

Issue 2290203002: Delete Timing class, timing.h, and update all users. (Closed)
Patch Set: Fix copy-paste error in rtpdataengine.cc. Created 4 years, 3 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
« no previous file with comments | « webrtc/media/base/rtpdataengine.h ('k') | webrtc/media/base/rtpdataengine_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/media/base/rtpdataengine.h" 11 #include "webrtc/media/base/rtpdataengine.h"
12 12
13 #include "webrtc/base/copyonwritebuffer.h" 13 #include "webrtc/base/copyonwritebuffer.h"
14 #include "webrtc/base/helpers.h" 14 #include "webrtc/base/helpers.h"
15 #include "webrtc/base/logging.h" 15 #include "webrtc/base/logging.h"
16 #include "webrtc/base/ratelimiter.h" 16 #include "webrtc/base/ratelimiter.h"
17 #include "webrtc/base/timing.h"
18 #include "webrtc/media/base/codec.h" 17 #include "webrtc/media/base/codec.h"
19 #include "webrtc/media/base/mediaconstants.h" 18 #include "webrtc/media/base/mediaconstants.h"
20 #include "webrtc/media/base/rtputils.h" 19 #include "webrtc/media/base/rtputils.h"
21 #include "webrtc/media/base/streamparams.h" 20 #include "webrtc/media/base/streamparams.h"
22 21
23 namespace cricket { 22 namespace cricket {
24 23
25 // We want to avoid IP fragmentation. 24 // We want to avoid IP fragmentation.
26 static const size_t kDataMaxRtpPacketLen = 1200U; 25 static const size_t kDataMaxRtpPacketLen = 1200U;
27 // We reserve space after the RTP header for future wiggle room. 26 // We reserve space after the RTP header for future wiggle room.
28 static const unsigned char kReservedSpace[] = { 27 static const unsigned char kReservedSpace[] = {
29 0x00, 0x00, 0x00, 0x00 28 0x00, 0x00, 0x00, 0x00
30 }; 29 };
31 30
32 // Amount of overhead SRTP may take. We need to leave room in the 31 // Amount of overhead SRTP may take. We need to leave room in the
33 // buffer for it, otherwise SRTP will fail later. If SRTP ever uses 32 // buffer for it, otherwise SRTP will fail later. If SRTP ever uses
34 // more than this, we need to increase this number. 33 // more than this, we need to increase this number.
35 static const size_t kMaxSrtpHmacOverhead = 16; 34 static const size_t kMaxSrtpHmacOverhead = 16;
36 35
37 RtpDataEngine::RtpDataEngine() { 36 RtpDataEngine::RtpDataEngine() {
38 data_codecs_.push_back( 37 data_codecs_.push_back(
39 DataCodec(kGoogleRtpDataCodecId, kGoogleRtpDataCodecName)); 38 DataCodec(kGoogleRtpDataCodecId, kGoogleRtpDataCodecName));
40 SetTiming(new rtc::Timing());
41 } 39 }
42 40
43 DataMediaChannel* RtpDataEngine::CreateChannel( 41 DataMediaChannel* RtpDataEngine::CreateChannel(
44 DataChannelType data_channel_type) { 42 DataChannelType data_channel_type) {
45 if (data_channel_type != DCT_RTP) { 43 if (data_channel_type != DCT_RTP) {
46 return NULL; 44 return NULL;
47 } 45 }
48 return new RtpDataMediaChannel(timing_.get()); 46 return new RtpDataMediaChannel();
49 } 47 }
50 48
51 bool FindCodecByName(const std::vector<DataCodec>& codecs, 49 bool FindCodecByName(const std::vector<DataCodec>& codecs,
52 const std::string& name, DataCodec* codec_out) { 50 const std::string& name, DataCodec* codec_out) {
53 std::vector<DataCodec>::const_iterator iter; 51 std::vector<DataCodec>::const_iterator iter;
54 for (iter = codecs.begin(); iter != codecs.end(); ++iter) { 52 for (iter = codecs.begin(); iter != codecs.end(); ++iter) {
55 if (iter->name == name) { 53 if (iter->name == name) {
56 *codec_out = *iter; 54 *codec_out = *iter;
57 return true; 55 return true;
58 } 56 }
59 } 57 }
60 return false; 58 return false;
61 } 59 }
62 60
63 RtpDataMediaChannel::RtpDataMediaChannel(rtc::Timing* timing) { 61 RtpDataMediaChannel::RtpDataMediaChannel() {
64 Construct(timing); 62 Construct();
65 } 63 }
66 64
67 RtpDataMediaChannel::RtpDataMediaChannel() { 65 void RtpDataMediaChannel::Construct() {
68 Construct(NULL);
69 }
70
71 void RtpDataMediaChannel::Construct(rtc::Timing* timing) {
72 sending_ = false; 66 sending_ = false;
73 receiving_ = false; 67 receiving_ = false;
74 timing_ = timing;
75 send_limiter_.reset(new rtc::RateLimiter(kDataMaxBandwidth / 8, 1.0)); 68 send_limiter_.reset(new rtc::RateLimiter(kDataMaxBandwidth / 8, 1.0));
76 } 69 }
77 70
78 71
79 RtpDataMediaChannel::~RtpDataMediaChannel() { 72 RtpDataMediaChannel::~RtpDataMediaChannel() {
80 std::map<uint32_t, RtpClock*>::const_iterator iter; 73 std::map<uint32_t, RtpClock*>::const_iterator iter;
81 for (iter = rtp_clock_by_send_ssrc_.begin(); 74 for (iter = rtp_clock_by_send_ssrc_.begin();
82 iter != rtp_clock_by_send_ssrc_.end(); 75 iter != rtp_clock_by_send_ssrc_.end();
83 ++iter) { 76 ++iter) {
84 delete iter->second; 77 delete iter->second;
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 << kGoogleRtpDataCodecName; 299 << kGoogleRtpDataCodecName;
307 return false; 300 return false;
308 } 301 }
309 302
310 size_t packet_len = (kMinRtpPacketLen + sizeof(kReservedSpace) + 303 size_t packet_len = (kMinRtpPacketLen + sizeof(kReservedSpace) +
311 payload.size() + kMaxSrtpHmacOverhead); 304 payload.size() + kMaxSrtpHmacOverhead);
312 if (packet_len > kDataMaxRtpPacketLen) { 305 if (packet_len > kDataMaxRtpPacketLen) {
313 return false; 306 return false;
314 } 307 }
315 308
316 double now = timing_->TimerNow(); 309 double now =
310 rtc::TimeMicros() / static_cast<double>(rtc::kNumMicrosecsPerSec);
317 311
318 if (!send_limiter_->CanUse(packet_len, now)) { 312 if (!send_limiter_->CanUse(packet_len, now)) {
319 LOG(LS_VERBOSE) << "Dropped data packet of len=" << packet_len 313 LOG(LS_VERBOSE) << "Dropped data packet of len=" << packet_len
320 << "; already sent " << send_limiter_->used_in_period() 314 << "; already sent " << send_limiter_->used_in_period()
321 << "/" << send_limiter_->max_per_period(); 315 << "/" << send_limiter_->max_per_period();
322 return false; 316 return false;
323 } 317 }
324 318
325 RtpHeader header; 319 RtpHeader header;
326 header.payload_type = found_codec.id; 320 header.payload_type = found_codec.id;
(...skipping 16 matching lines...) Expand all
343 337
344 MediaChannel::SendPacket(&packet, rtc::PacketOptions()); 338 MediaChannel::SendPacket(&packet, rtc::PacketOptions());
345 send_limiter_->Use(packet_len, now); 339 send_limiter_->Use(packet_len, now);
346 if (result) { 340 if (result) {
347 *result = SDR_SUCCESS; 341 *result = SDR_SUCCESS;
348 } 342 }
349 return true; 343 return true;
350 } 344 }
351 345
352 } // namespace cricket 346 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/base/rtpdataengine.h ('k') | webrtc/media/base/rtpdataengine_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698