OLD | NEW |
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/rtcp/rtcp_sender.h" | 5 #include "media/cast/rtcp/rtcp_sender.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/big_endian.h" | 12 #include "base/big_endian.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "media/cast/cast_environment.h" | 14 #include "media/cast/cast_environment.h" |
15 #include "media/cast/rtcp/rtcp_defines.h" | 15 #include "media/cast/rtcp/rtcp_defines.h" |
16 #include "media/cast/rtcp/rtcp_utility.h" | 16 #include "media/cast/rtcp/rtcp_utility.h" |
17 #include "media/cast/transport/cast_transport_defines.h" | 17 #include "media/cast/transport/cast_transport_defines.h" |
18 #include "media/cast/transport/pacing/paced_sender.h" | 18 #include "media/cast/transport/pacing/paced_sender.h" |
19 | 19 |
20 namespace media { | 20 namespace media { |
21 namespace cast { | 21 namespace cast { |
22 namespace { | 22 namespace { |
23 | 23 |
24 // Max delta is 4095 milliseconds because we need to be able to encode it in | 24 // Max delta is 4095 milliseconds because we need to be able to encode it in |
25 // 12 bits. | 25 // 12 bits. |
26 const int64 kMaxWireFormatTimeDeltaMs = INT64_C(0xfff); | 26 const int64 kMaxWireFormatTimeDeltaMs = INT64_C(0xfff); |
27 | 27 |
28 // Converts a log event type to an integer value. | |
29 // NOTE: We have only allocated 4 bits to represent the type of event over the | |
30 // wire. Therefore, this function can only return values from 0 to 15. | |
31 int ConvertEventTypeToWireFormat(const CastLoggingEvent& event) { | |
32 switch (event) { | |
33 case kAudioAckSent: | |
34 return 1; | |
35 case kAudioPlayoutDelay: | |
36 return 2; | |
37 case kAudioFrameDecoded: | |
38 return 3; | |
39 case kAudioPacketReceived: | |
40 return 4; | |
41 case kVideoAckSent: | |
42 return 5; | |
43 case kVideoFrameDecoded: | |
44 return 6; | |
45 case kVideoRenderDelay: | |
46 return 7; | |
47 case kVideoPacketReceived: | |
48 return 8; | |
49 case kDuplicateAudioPacketReceived: | |
50 return 9; | |
51 case kDuplicateVideoPacketReceived: | |
52 return 10; | |
53 default: | |
54 return 0; // Not an interesting event. | |
55 } | |
56 } | |
57 | |
58 uint16 MergeEventTypeAndTimestampForWireFormat( | 28 uint16 MergeEventTypeAndTimestampForWireFormat( |
59 const CastLoggingEvent& event, | 29 const CastLoggingEvent& event, |
60 const base::TimeDelta& time_delta) { | 30 const base::TimeDelta& time_delta) { |
61 int64 time_delta_ms = time_delta.InMilliseconds(); | 31 int64 time_delta_ms = time_delta.InMilliseconds(); |
62 | 32 |
63 DCHECK_GE(time_delta_ms, 0); | 33 DCHECK_GE(time_delta_ms, 0); |
64 DCHECK_LE(time_delta_ms, kMaxWireFormatTimeDeltaMs); | 34 DCHECK_LE(time_delta_ms, kMaxWireFormatTimeDeltaMs); |
65 | 35 |
66 uint16 time_delta_12_bits = | 36 uint16 time_delta_12_bits = |
67 static_cast<uint16>(time_delta_ms & kMaxWireFormatTimeDeltaMs); | 37 static_cast<uint16>(time_delta_ms & kMaxWireFormatTimeDeltaMs); |
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 << "Not enough buffer space."; | 822 << "Not enough buffer space."; |
853 | 823 |
854 VLOG(3) << "number of frames: " << *number_of_frames; | 824 VLOG(3) << "number of frames: " << *number_of_frames; |
855 VLOG(3) << "total messages to send: " << *total_number_of_messages_to_send; | 825 VLOG(3) << "total messages to send: " << *total_number_of_messages_to_send; |
856 VLOG(3) << "rtcp log size: " << *rtcp_log_size; | 826 VLOG(3) << "rtcp log size: " << *rtcp_log_size; |
857 return *number_of_frames > 0; | 827 return *number_of_frames > 0; |
858 } | 828 } |
859 | 829 |
860 } // namespace cast | 830 } // namespace cast |
861 } // namespace media | 831 } // namespace media |
OLD | NEW |