OLD | NEW |
---|---|
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 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 } | 58 } |
59 | 59 |
60 int AudioDecoder::IncomingPacket(const uint8_t* payload, | 60 int AudioDecoder::IncomingPacket(const uint8_t* payload, |
61 size_t payload_len, | 61 size_t payload_len, |
62 uint16_t rtp_sequence_number, | 62 uint16_t rtp_sequence_number, |
63 uint32_t rtp_timestamp, | 63 uint32_t rtp_timestamp, |
64 uint32_t arrival_timestamp) { | 64 uint32_t arrival_timestamp) { |
65 return 0; | 65 return 0; |
66 } | 66 } |
67 | 67 |
68 AudioDecoder::PacketSplits AudioDecoder::SplitPacket(const uint8_t* payload, | |
69 size_t payload_len) const { | |
70 return {PacketSplit{0, payload_len, 0}}; | |
71 } | |
72 | |
68 int AudioDecoder::ErrorCode() { return 0; } | 73 int AudioDecoder::ErrorCode() { return 0; } |
69 | 74 |
70 int AudioDecoder::PacketDuration(const uint8_t* encoded, | 75 int AudioDecoder::PacketDuration(const uint8_t* encoded, |
71 size_t encoded_len) const { | 76 size_t encoded_len) const { |
72 return kNotImplemented; | 77 return kNotImplemented; |
73 } | 78 } |
74 | 79 |
75 int AudioDecoder::PacketDurationRedundant(const uint8_t* encoded, | 80 int AudioDecoder::PacketDurationRedundant(const uint8_t* encoded, |
76 size_t encoded_len) const { | 81 size_t encoded_len) const { |
77 return kNotImplemented; | 82 return kNotImplemented; |
(...skipping 10 matching lines...) Expand all Loading... | |
88 case 1: | 93 case 1: |
89 return kSpeech; | 94 return kSpeech; |
90 case 2: | 95 case 2: |
91 return kComfortNoise; | 96 return kComfortNoise; |
92 default: | 97 default: |
93 assert(false); | 98 assert(false); |
94 return kSpeech; | 99 return kSpeech; |
95 } | 100 } |
96 } | 101 } |
97 | 102 |
103 AudioDecoder::PacketSplits AudioDecoder::SplitBySamples( | |
104 const uint8_t* payload, | |
105 size_t payload_len, | |
106 size_t bytes_per_ms, | |
107 uint32_t timestamps_per_ms) { | |
kwiberg-webrtc
2016/08/26 12:39:24
This is the sort of function that should have a un
ossu
2016/08/26 13:05:29
It does. Several of them even.
Though, granted, it
kwiberg-webrtc
2016/08/26 22:05:13
It's arguably not a unit test of this function in
| |
108 PacketSplits splits; | |
109 RTC_DCHECK(payload); | |
110 | |
111 size_t split_size_bytes = payload_len; | |
112 | |
113 // Find a "chunk size" >= 20 ms and < 40 ms. | |
114 size_t min_chunk_size = bytes_per_ms * 20; | |
kwiberg-webrtc
2016/08/26 12:39:24
const
ossu
2016/08/26 13:05:29
Hey, don't blame me, I just clean up around here!
kwiberg-webrtc
2016/08/26 22:05:13
Yeah, I think I wrote this comment before I realiz
| |
115 // Reduce the split size by half as long as |split_size_bytes| is at least | |
116 // twice the minimum chunk size (so that the resulting size is at least as | |
117 // large as the minimum chunk size). | |
118 while (split_size_bytes >= 2 * min_chunk_size) { | |
119 split_size_bytes >>= 1; | |
kwiberg-webrtc
2016/08/26 12:39:24
Less cleverly written as split_size_bytes /= 2;
I
ossu
2016/08/26 13:05:29
Yeah, I mean the code can be improved but I've aim
kwiberg-webrtc
2016/08/26 22:05:13
sgtm.
| |
120 } | |
121 uint32_t timestamps_per_chunk = static_cast<uint32_t>( | |
kwiberg-webrtc
2016/08/26 12:39:24
const
| |
122 split_size_bytes * timestamps_per_ms / bytes_per_ms); | |
123 PacketSplit split = {0, split_size_bytes, 0}; | |
124 size_t len = payload_len; | |
125 for (len = payload_len; | |
126 len >= (2 * split_size_bytes); | |
127 len -= split_size_bytes) { | |
128 splits.push_back(split); | |
129 split.byte_offset += split_size_bytes; | |
130 split.timestamp_offset += timestamps_per_chunk; | |
131 } | |
132 | |
133 if (len > 0) { | |
134 split.num_bytes = len; | |
135 splits.push_back(split); | |
136 } | |
137 | |
138 return splits; | |
139 } | |
140 | |
98 } // namespace webrtc | 141 } // namespace webrtc |
OLD | NEW |