OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 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/base/transformadapter.h" | 11 #include "webrtc/base/transformadapter.h" |
12 | 12 |
13 #include <string.h> | 13 #include <string.h> |
14 | 14 |
| 15 #include "webrtc/base/checks.h" |
15 #include "webrtc/base/common.h" | 16 #include "webrtc/base/common.h" |
16 | 17 |
17 namespace rtc { | 18 namespace rtc { |
18 | 19 |
19 /////////////////////////////////////////////////////////////////////////////// | 20 /////////////////////////////////////////////////////////////////////////////// |
20 | 21 |
21 TransformAdapter::TransformAdapter(StreamInterface * stream, | 22 TransformAdapter::TransformAdapter(StreamInterface * stream, |
22 TransformInterface * transform, | 23 TransformInterface * transform, |
23 bool direction_read) | 24 bool direction_read) |
24 : StreamAdapterInterface(stream), transform_(transform), | 25 : StreamAdapterInterface(stream), transform_(transform), |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 size_t out_len = sizeof(buffer_) - len_; | 116 size_t out_len = sizeof(buffer_) - len_; |
116 StreamResult result = transform_->Transform(data, &in_len, | 117 StreamResult result = transform_->Transform(data, &in_len, |
117 buffer_ + len_, &out_len, | 118 buffer_ + len_, &out_len, |
118 (state_ == ST_FLUSHING)); | 119 (state_ == ST_FLUSHING)); |
119 | 120 |
120 ASSERT(result != SR_BLOCK); | 121 ASSERT(result != SR_BLOCK); |
121 if (result == SR_EOS) { | 122 if (result == SR_EOS) { |
122 // Note: Don't signal SR_EOS this iteration, unless no data written | 123 // Note: Don't signal SR_EOS this iteration, unless no data written |
123 state_ = ST_COMPLETE; | 124 state_ = ST_COMPLETE; |
124 } else if (result == SR_ERROR) { | 125 } else if (result == SR_ERROR) { |
125 ASSERT(false); // When this happens, think about what should be done | 126 RTC_NOTREACHED(); // When this happens, think about what should be done |
126 state_ = ST_ERROR; | 127 state_ = ST_ERROR; |
127 error_ = -1; // TODO: propagate error | 128 error_ = -1; // TODO: propagate error |
128 break; | 129 break; |
129 } | 130 } |
130 | 131 |
131 len_ = out_len; | 132 len_ = out_len; |
132 bytes_written = in_len; | 133 bytes_written = in_len; |
133 } | 134 } |
134 | 135 |
135 size_t pos = 0; | 136 size_t pos = 0; |
136 while (pos < len_) { | 137 while (pos < len_) { |
137 size_t subwritten; | 138 size_t subwritten; |
138 StreamResult result = StreamAdapterInterface::Write(buffer_ + pos, | 139 StreamResult result = StreamAdapterInterface::Write(buffer_ + pos, |
139 len_ - pos, | 140 len_ - pos, |
140 &subwritten, | 141 &subwritten, |
141 &error_); | 142 &error_); |
142 if (result == SR_BLOCK) { | 143 if (result == SR_BLOCK) { |
143 ASSERT(false); // TODO: we should handle this | 144 RTC_NOTREACHED(); // We should handle this |
144 return SR_BLOCK; | 145 return SR_BLOCK; |
145 } else if (result == SR_ERROR) { | 146 } else if (result == SR_ERROR) { |
146 state_ = ST_ERROR; | 147 state_ = ST_ERROR; |
147 break; | 148 break; |
148 } else if (result == SR_EOS) { | 149 } else if (result == SR_EOS) { |
149 state_ = ST_COMPLETE; | 150 state_ = ST_COMPLETE; |
150 break; | 151 break; |
151 } | 152 } |
152 | 153 |
153 pos += subwritten; | 154 pos += subwritten; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 | 189 |
189 bool TransformAdapter::ReserveSize(size_t size) { | 190 bool TransformAdapter::ReserveSize(size_t size) { |
190 return true; | 191 return true; |
191 } | 192 } |
192 | 193 |
193 bool TransformAdapter::Rewind() { | 194 bool TransformAdapter::Rewind() { |
194 return false; | 195 return false; |
195 } | 196 } |
196 | 197 |
197 } // namespace rtc | 198 } // namespace rtc |
OLD | NEW |