Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit 7c4f48e

Browse files
authored
Add BufferedDataBytes API for QuicStream. (#552)
1 parent fa8b907 commit 7c4f48e

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

talk/owt/sdk/base/stream.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ QuicStream::~QuicStream() {
730730
}
731731

732732
size_t QuicStream::Write(uint8_t* data, size_t length) {
733-
if (quic_stream_ && !fin_read_ && data != nullptr && length > 0) {
733+
if (quic_stream_ && data != nullptr && length > 0) {
734734
return quic_stream_->Write(data, length);
735735
}
736736
return 0;
@@ -752,6 +752,14 @@ size_t QuicStream::ReadableBytes() const {
752752
}
753753
}
754754

755+
uint64_t QuicStream::BufferedDataBytes() const {
756+
if (quic_stream_) {
757+
return quic_stream_->BufferedDataBytes();
758+
} else {
759+
return 0;
760+
}
761+
}
762+
755763
std::shared_ptr<owt::base::QuicStream> LocalStream::Stream() {
756764
return quic_stream_;
757765
}

talk/owt/sdk/include/cpp/owt/base/stream.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,11 @@ class QuicStream : public owt::quic::WebTransportStreamInterface::Visitor {
207207
@return Bytes of data available on the stream.
208208
*/
209209
size_t ReadableBytes() const;
210+
/**
211+
@brief Returns the amount of data pending to be sent on the stream.
212+
@return Bytes of data pending to be sent.
213+
*/
214+
uint64_t BufferedDataBytes() const;
210215
void SetVisitor(owt::quic::WebTransportStreamInterface::Visitor* visitor) {
211216
if (quic_stream_ && visitor) {
212217
quic_stream_->SetVisitor(visitor);
@@ -224,7 +229,6 @@ class QuicStream : public owt::quic::WebTransportStreamInterface::Visitor {
224229
// OnFinRead the stream is no longer readable/writable
225230
fin_read_ = true;
226231
can_read_ = false;
227-
can_write_ = false;
228232
}
229233
/** @endcond */
230234
private:

0 commit comments

Comments
 (0)