blob: e6b74b49aca0e58c1dafb3bcd6b9a6ac761061fa [file] [log] [blame]
henrike@webrtc.orgf0488722014-05-13 18:00:26 +00001/*
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 */
Jonas Olssona4d87372019-07-05 19:08:33 +020010#include "rtc_base/stream.h"
11
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000012#include <errno.h>
Yves Gerey988cc082018-10-23 12:03:01 +020013#include <string.h>
Jonas Olssona4d87372019-07-05 19:08:33 +020014
andresp@webrtc.orgff689be2015-02-12 11:54:26 +000015#include <algorithm>
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000016#include <string>
andresp@webrtc.orgff689be2015-02-12 11:54:26 +000017
Harald Alvestrand11840ce2022-11-10 10:50:50 +000018#include "api/array_view.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "rtc_base/checks.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020020#include "rtc_base/thread.h"
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000021
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000022namespace rtc {
23
24///////////////////////////////////////////////////////////////////////////////
25// StreamInterface
26///////////////////////////////////////////////////////////////////////////////
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000027
Yves Gerey665174f2018-06-19 15:03:05 +020028StreamResult StreamInterface::WriteAll(const void* data,
29 size_t data_len,
30 size_t* written,
31 int* error) {
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000032 StreamResult result = SR_SUCCESS;
33 size_t total_written = 0, current_written;
34 while (total_written < data_len) {
Harald Alvestrand11840ce2022-11-10 10:50:50 +000035 result = Write(ArrayView<const uint8_t>(
36 reinterpret_cast<const uint8_t*>(data) + total_written,
37 data_len - total_written),
38 current_written, *error);
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000039 if (result != SR_SUCCESS)
40 break;
41 total_written += current_written;
42 }
43 if (written)
44 *written = total_written;
45 return result;
46}
47
kwiberg@webrtc.org67186fe2015-03-09 22:21:53 +000048bool StreamInterface::Flush() {
49 return false;
50}
51
Yves Gerey665174f2018-06-19 15:03:05 +020052StreamInterface::StreamInterface() {}
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000053
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000054} // namespace rtc