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 FRAMEWORKS_INNERKITSIMPL_STREAM_INCLUDE_BUFFER_PACKER_STREAM_H
17 #define FRAMEWORKS_INNERKITSIMPL_STREAM_INCLUDE_BUFFER_PACKER_STREAM_H
18 
19 #include <string>
20 #include "nocopyable.h"
21 #include "packer_stream.h"
22 
23 namespace OHOS {
24 namespace Media {
25 class BufferPackerStream : public PackerStream {
26 public:
27     BufferPackerStream(uint8_t *outputData, uint32_t maxSize);
28     ~BufferPackerStream() = default;
29     bool Write(const uint8_t *buffer, uint32_t size) override;
30     int64_t BytesWritten() override;
31     bool GetCapicity(size_t &size) override;
32 
GetAddr()33     uint8_t* GetAddr() const override
34     {
35         return outputData_;
36     }
37 
SetOffset(uint32_t offset)38     void SetOffset(uint32_t offset) override
39     {
40         offset_ = offset;
41     }
42 
43     ImagePlugin::OutputStreamType GetType() override;
44 private:
45     DISALLOW_COPY(BufferPackerStream);
46 
47     uint8_t *outputData_ = nullptr;
48     uint32_t maxSize_ = 0;
49     int64_t offset_ = 0;
50 };
51 } // namespace Media
52 } // namespace OHOS
53 
54 #endif // FRAMEWORKS_INNERKITSIMPL_STREAM_INCLUDE_BUFFER_PACKER_STREAM_H
55