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

Side by Side Diff: media/cast/cast_defines.h

Issue 1515433002: Replace uses of raw uint32's with a type-checked RtpTimeTicks data type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix in chrome_common.gypi to avoid building cast_messages.* on Android. Created 4 years, 12 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
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 #ifndef MEDIA_CAST_CAST_DEFINES_H_ 5 #ifndef MEDIA_CAST_CAST_DEFINES_H_
6 #define MEDIA_CAST_CAST_DEFINES_H_ 6 #define MEDIA_CAST_CAST_DEFINES_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 11
12 namespace media { 12 namespace media {
13 namespace cast { 13 namespace cast {
14 14
15 // TODO(miu): All remaining functions in this file are to be replaced with 15 // TODO(miu): All remaining functions in this file are to be replaced with
16 // methods in well-defined data types. http://crbug.com/530839 16 // methods in well-defined data types. http://crbug.com/530839
17 17
18 inline bool IsNewerFrameId(uint32_t frame_id, uint32_t prev_frame_id) { 18 inline bool IsNewerFrameId(uint32_t frame_id, uint32_t prev_frame_id) {
19 return (frame_id != prev_frame_id) && 19 return (frame_id != prev_frame_id) &&
20 static_cast<uint32_t>(frame_id - prev_frame_id) < 0x80000000; 20 static_cast<uint32_t>(frame_id - prev_frame_id) < 0x80000000;
21 } 21 }
22 22
23 inline bool IsNewerRtpTimestamp(uint32_t timestamp, uint32_t prev_timestamp) {
24 return (timestamp != prev_timestamp) &&
25 static_cast<uint32_t>(timestamp - prev_timestamp) < 0x80000000;
26 }
27
28 inline bool IsOlderFrameId(uint32_t frame_id, uint32_t prev_frame_id) { 23 inline bool IsOlderFrameId(uint32_t frame_id, uint32_t prev_frame_id) {
29 return (frame_id == prev_frame_id) || IsNewerFrameId(prev_frame_id, frame_id); 24 return (frame_id == prev_frame_id) || IsNewerFrameId(prev_frame_id, frame_id);
30 } 25 }
31 26
32 inline bool IsNewerPacketId(uint16_t packet_id, uint16_t prev_packet_id) { 27 inline bool IsNewerPacketId(uint16_t packet_id, uint16_t prev_packet_id) {
33 return (packet_id != prev_packet_id) && 28 return (packet_id != prev_packet_id) &&
34 static_cast<uint16_t>(packet_id - prev_packet_id) < 0x8000; 29 static_cast<uint16_t>(packet_id - prev_packet_id) < 0x8000;
35 } 30 }
36 31
37 inline bool IsNewerSequenceNumber(uint16_t sequence_number, 32 inline bool IsNewerSequenceNumber(uint16_t sequence_number,
38 uint16_t prev_sequence_number) { 33 uint16_t prev_sequence_number) {
39 // Same function as IsNewerPacketId just different data and name. 34 // Same function as IsNewerPacketId just different data and name.
40 return IsNewerPacketId(sequence_number, prev_sequence_number); 35 return IsNewerPacketId(sequence_number, prev_sequence_number);
41 } 36 }
42 37
43 inline base::TimeDelta RtpDeltaToTimeDelta(int64_t rtp_delta,
44 int rtp_timebase) {
45 DCHECK_GT(rtp_timebase, 0);
46 return rtp_delta * base::TimeDelta::FromSeconds(1) / rtp_timebase;
47 }
48
49 inline int64_t TimeDeltaToRtpDelta(base::TimeDelta delta, int rtp_timebase) {
50 DCHECK_GT(rtp_timebase, 0);
51 return delta * rtp_timebase / base::TimeDelta::FromSeconds(1);
52 }
53
54 } // namespace cast 38 } // namespace cast
55 } // namespace media 39 } // namespace media
56 40
57 #endif // MEDIA_CAST_CAST_DEFINES_H_ 41 #endif // MEDIA_CAST_CAST_DEFINES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698