1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef RAW_STREAM_DATA_H 17 #define RAW_STREAM_DATA_H 18 19 #include <cstdint> 20 #include <memory> 21 #include <sys/types.h> 22 23 #include "i_stream.h" 24 25 namespace Communication { 26 namespace SoftBus { 27 class RawStreamData : public IStream { 28 public: 29 RawStreamData() = default; 30 ~RawStreamData() override = default; 31 static constexpr int BYTE_TO_BIT = 8; 32 static constexpr int INT_TO_BYTE = 0xff; 33 static constexpr int FRAME_HEADER_LEN = 4; 34 35 int InitStreamData(std::unique_ptr<char[]> buffer, ssize_t bufLen, std::unique_ptr<char[]> extBuffer, 36 ssize_t extLen); 37 38 std::unique_ptr<char[]> GetBuffer() override; 39 ssize_t GetBufferLen() const override; 40 41 static void InsertBufferLength(int num, int length, uint8_t *output); 42 43 private: SetTimeStamp(uint32_t timestamp)44 void SetTimeStamp(uint32_t timestamp) override 45 { 46 static_cast<void>(timestamp); 47 } GetTimeStamp()48 uint32_t GetTimeStamp() const override 49 { 50 return 0; 51 } 52 GetExtBuffer()53 std::unique_ptr<char[]> GetExtBuffer() override 54 { 55 return nullptr; 56 } 57 GetExtBufferLen()58 ssize_t GetExtBufferLen() const override 59 { 60 return 0; 61 } 62 GetSeqNum()63 int GetSeqNum() const override 64 { 65 return 0; 66 } 67 GetStreamId()68 uint32_t GetStreamId() const override 69 { 70 return 0; 71 } 72 GetStreamFrameInfo()73 const StreamFrameInfo* GetStreamFrameInfo() const override 74 { 75 return nullptr; 76 } 77 78 std::unique_ptr<char[]> streamData_ = nullptr; 79 ssize_t streamLen_ = 0; 80 }; 81 } // namespace SoftBus 82 } // namespace Communication 83 #endif