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 OUTPUT_DATA_STREAM_H
17 #define OUTPUT_DATA_STREAM_H
18 
19 #include <cinttypes>
20 
21 namespace OHOS {
22 namespace ImagePlugin {
23 enum class OutputStreamType : int32_t {
24     UNKNOWN = 0,
25     BUFFER_PACKER = 1,
26     FILE_PACKER = 2,
27     OSTREAM_PACKER = 3,
28 };
29 
30 class OutputDataStream {
31 public:
~OutputDataStream()32     virtual ~OutputDataStream() {}
33     virtual bool Write(const uint8_t *buffer, uint32_t size) = 0;
Flush()34     virtual void Flush() {}
35     // False means no limit, true needs return act capicity by size
GetCapicity(size_t & size)36     virtual bool GetCapicity(size_t &size)
37     {
38         return false;
39     }
GetCurrentSize(size_t & size)40     virtual bool GetCurrentSize(size_t &size)
41     {
42         return false;
43     }
44 
GetAddr()45     virtual uint8_t* GetAddr() const
46     {
47         return nullptr;
48     }
49 
SetOffset(uint32_t offset)50     virtual void SetOffset(uint32_t offset) {}
51 
GetType()52     virtual OutputStreamType GetType() { return OutputStreamType::UNKNOWN; }
53 };
54 } // namespace ImagePlugin
55 } // namespace OHOS
56 
57 #endif // OUTPUT_DATA_STREAM_H
58