blob: 30c767888ca0c71ddbcb8054b5e6cc465d1c7c80 [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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020018#include "rtc_base/checks.h"
Yves Gerey988cc082018-10-23 12:03:01 +020019#include "rtc_base/location.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) {
35 result = Write(static_cast<const char*>(data) + total_written,
36 data_len - total_written, &current_written, error);
37 if (result != SR_SUCCESS)
38 break;
39 total_written += current_written;
40 }
41 if (written)
42 *written = total_written;
43 return result;
44}
45
kwiberg@webrtc.org67186fe2015-03-09 22:21:53 +000046bool StreamInterface::Flush() {
47 return false;
48}
49
Yves Gerey665174f2018-06-19 15:03:05 +020050StreamInterface::StreamInterface() {}
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000051
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000052} // namespace rtc