2014-05-13 18:00:26 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright 2004 The WebRTC Project Authors. All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
2019-07-05 19:08:33 +02:00
|
|
|
#include "rtc_base/stream.h"
|
|
|
|
|
|
2014-05-13 18:00:26 +00:00
|
|
|
#include <errno.h>
|
2018-10-23 12:03:01 +02:00
|
|
|
#include <string.h>
|
2019-07-05 19:08:33 +02:00
|
|
|
|
2015-02-12 11:54:26 +00:00
|
|
|
#include <algorithm>
|
2014-05-13 18:00:26 +00:00
|
|
|
#include <string>
|
2015-02-12 11:54:26 +00:00
|
|
|
|
2022-11-10 10:50:50 +00:00
|
|
|
#include "api/array_view.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/checks.h"
|
|
|
|
|
#include "rtc_base/thread.h"
|
2014-05-13 18:00:26 +00:00
|
|
|
|
|
|
|
|
namespace rtc {
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// StreamInterface
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2018-06-19 15:03:05 +02:00
|
|
|
StreamResult StreamInterface::WriteAll(const void* data,
|
|
|
|
|
size_t data_len,
|
|
|
|
|
size_t* written,
|
|
|
|
|
int* error) {
|
2014-05-13 18:00:26 +00:00
|
|
|
StreamResult result = SR_SUCCESS;
|
|
|
|
|
size_t total_written = 0, current_written;
|
|
|
|
|
while (total_written < data_len) {
|
2022-11-10 10:50:50 +00:00
|
|
|
result = Write(ArrayView<const uint8_t>(
|
|
|
|
|
reinterpret_cast<const uint8_t*>(data) + total_written,
|
|
|
|
|
data_len - total_written),
|
|
|
|
|
current_written, *error);
|
2014-05-13 18:00:26 +00:00
|
|
|
if (result != SR_SUCCESS)
|
|
|
|
|
break;
|
|
|
|
|
total_written += current_written;
|
|
|
|
|
}
|
|
|
|
|
if (written)
|
|
|
|
|
*written = total_written;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-09 22:21:53 +00:00
|
|
|
bool StreamInterface::Flush() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-19 15:03:05 +02:00
|
|
|
StreamInterface::StreamInterface() {}
|
2014-05-13 18:00:26 +00:00
|
|
|
|
|
|
|
|
} // namespace rtc
|