1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10 #include "rtc_base/stream.h"
11
12 #include <errno.h>
13 #include <string.h>
14
15 #include <algorithm>
16 #include <string>
17
18 #include "api/array_view.h"
19 #include "rtc_base/checks.h"
20 #include "rtc_base/thread.h"
21
22 namespace rtc {
23
24 ///////////////////////////////////////////////////////////////////////////////
25 // StreamInterface
26 ///////////////////////////////////////////////////////////////////////////////
27
WriteAll(const void * data,size_t data_len,size_t * written,int * error)28 StreamResult StreamInterface::WriteAll(const void* data,
29 size_t data_len,
30 size_t* written,
31 int* error) {
32 StreamResult result = SR_SUCCESS;
33 size_t total_written = 0, current_written;
34 while (total_written < data_len) {
35 result = Write(ArrayView<const uint8_t>(
36 reinterpret_cast<const uint8_t*>(data) + total_written,
37 data_len - total_written),
38 current_written, *error);
39 if (result != SR_SUCCESS)
40 break;
41 total_written += current_written;
42 }
43 if (written)
44 *written = total_written;
45 return result;
46 }
47
Flush()48 bool StreamInterface::Flush() {
49 return false;
50 }
51
StreamInterface()52 StreamInterface::StreamInterface() {}
53
54 } // namespace rtc
55