| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // Even though several of these operations are related, you should | 118 // Even though several of these operations are related, you should |
| 119 // always use whichever operation is most relevant. For example, you may | 119 // always use whichever operation is most relevant. For example, you may |
| 120 // be tempted to use GetSize() and GetPosition() to deduce the result of | 120 // be tempted to use GetSize() and GetPosition() to deduce the result of |
| 121 // GetAvailable(). However, a stream which is read-once may support the | 121 // GetAvailable(). However, a stream which is read-once may support the |
| 122 // latter operation but not the former. | 122 // latter operation but not the former. |
| 123 // | 123 // |
| 124 | 124 |
| 125 // The following four methods are used to avoid copying data multiple times. | 125 // The following four methods are used to avoid copying data multiple times. |
| 126 | 126 |
| 127 // GetReadData returns a pointer to a buffer which is owned by the stream. | 127 // GetReadData returns a pointer to a buffer which is owned by the stream. |
| 128 // The buffer contains data_len bytes. NULL is returned if no data is | 128 // The buffer contains data_len bytes. null is returned if no data is |
| 129 // available, or if the method fails. If the caller processes the data, it | 129 // available, or if the method fails. If the caller processes the data, it |
| 130 // must call ConsumeReadData with the number of processed bytes. GetReadData | 130 // must call ConsumeReadData with the number of processed bytes. GetReadData |
| 131 // does not require a matching call to ConsumeReadData if the data is not | 131 // does not require a matching call to ConsumeReadData if the data is not |
| 132 // processed. Read and ConsumeReadData invalidate the buffer returned by | 132 // processed. Read and ConsumeReadData invalidate the buffer returned by |
| 133 // GetReadData. | 133 // GetReadData. |
| 134 virtual const void* GetReadData(size_t* data_len); | 134 virtual const void* GetReadData(size_t* data_len); |
| 135 virtual void ConsumeReadData(size_t used) {} | 135 virtual void ConsumeReadData(size_t used) {} |
| 136 | 136 |
| 137 // GetWriteBuffer returns a pointer to a buffer which is owned by the stream. | 137 // GetWriteBuffer returns a pointer to a buffer which is owned by the stream. |
| 138 // The buffer has a capacity of buf_len bytes. NULL is returned if there is | 138 // The buffer has a capacity of buf_len bytes. null is returned if there is |
| 139 // no buffer available, or if the method fails. The call may write data to | 139 // no buffer available, or if the method fails. The call may write data to |
| 140 // the buffer, and then call ConsumeWriteBuffer with the number of bytes | 140 // the buffer, and then call ConsumeWriteBuffer with the number of bytes |
| 141 // written. GetWriteBuffer does not require a matching call to | 141 // written. GetWriteBuffer does not require a matching call to |
| 142 // ConsumeWriteData if no data is written. Write, ForceWrite, and | 142 // ConsumeWriteData if no data is written. Write, ForceWrite, and |
| 143 // ConsumeWriteData invalidate the buffer returned by GetWriteBuffer. | 143 // ConsumeWriteData invalidate the buffer returned by GetWriteBuffer. |
| 144 // TODO: Allow the caller to specify a minimum buffer size. If the specified | 144 // TODO: Allow the caller to specify a minimum buffer size. If the specified |
| 145 // amount of buffer is not yet available, return NULL and Signal SE_WRITE | 145 // amount of buffer is not yet available, return null and Signal SE_WRITE |
| 146 // when it is available. If the requested amount is too large, return an | 146 // when it is available. If the requested amount is too large, return an |
| 147 // error. | 147 // error. |
| 148 virtual void* GetWriteBuffer(size_t* buf_len); | 148 virtual void* GetWriteBuffer(size_t* buf_len); |
| 149 virtual void ConsumeWriteBuffer(size_t used) {} | 149 virtual void ConsumeWriteBuffer(size_t used) {} |
| 150 | 150 |
| 151 // Write data_len bytes found in data, circumventing any throttling which | 151 // Write data_len bytes found in data, circumventing any throttling which |
| 152 // would could cause SR_BLOCK to be returned. Returns true if all the data | 152 // would could cause SR_BLOCK to be returned. Returns true if all the data |
| 153 // was written. Otherwise, the method is unsupported, or an unrecoverable | 153 // was written. Otherwise, the method is unsupported, or an unrecoverable |
| 154 // error occurred, and the error value is set. This method should be used | 154 // error occurred, and the error value is set. This method should be used |
| 155 // sparingly to write critical data which should not be throttled. A stream | 155 // sparingly to write critical data which should not be throttled. A stream |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 // Flow attempts to move bytes from source to sink via buffer of size | 696 // Flow attempts to move bytes from source to sink via buffer of size |
| 697 // buffer_len. The function returns SR_SUCCESS when source reaches | 697 // buffer_len. The function returns SR_SUCCESS when source reaches |
| 698 // end-of-stream (returns SR_EOS), and all the data has been written successful | 698 // end-of-stream (returns SR_EOS), and all the data has been written successful |
| 699 // to sink. Alternately, if source returns SR_BLOCK or SR_ERROR, or if sink | 699 // to sink. Alternately, if source returns SR_BLOCK or SR_ERROR, or if sink |
| 700 // returns SR_BLOCK, SR_ERROR, or SR_EOS, then the function immediately returns | 700 // returns SR_BLOCK, SR_ERROR, or SR_EOS, then the function immediately returns |
| 701 // with the unexpected StreamResult value. | 701 // with the unexpected StreamResult value. |
| 702 // data_len is the length of the valid data in buffer. in case of error | 702 // data_len is the length of the valid data in buffer. in case of error |
| 703 // this is the data that read from source but can't move to destination. | 703 // this is the data that read from source but can't move to destination. |
| 704 // as a pass in parameter, it indicates data in buffer that should move to sink | 704 // as a pass in parameter, it indicates data in buffer that should move to sink |
| 705 StreamResult Flow(StreamInterface* source, | 705 StreamResult Flow(StreamInterface* source, |
| 706 char* buffer, size_t buffer_len, | 706 char* buffer, |
| 707 StreamInterface* sink, size_t* data_len = NULL); | 707 size_t buffer_len, |
| 708 StreamInterface* sink, |
| 709 size_t* data_len = nullptr); |
| 708 | 710 |
| 709 /////////////////////////////////////////////////////////////////////////////// | 711 /////////////////////////////////////////////////////////////////////////////// |
| 710 | 712 |
| 711 } // namespace rtc | 713 } // namespace rtc |
| 712 | 714 |
| 713 #endif // WEBRTC_BASE_STREAM_H_ | 715 #endif // WEBRTC_BASE_STREAM_H_ |
| OLD | NEW |