11c1b0f19Sopenharmony_ci/*
21c1b0f19Sopenharmony_ci * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
31c1b0f19Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
41c1b0f19Sopenharmony_ci * you may not use this file except in compliance with the License.
51c1b0f19Sopenharmony_ci * You may obtain a copy of the License at
61c1b0f19Sopenharmony_ci *
71c1b0f19Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
81c1b0f19Sopenharmony_ci *
91c1b0f19Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
101c1b0f19Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
111c1b0f19Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
121c1b0f19Sopenharmony_ci * See the License for the specific language governing permissions and
131c1b0f19Sopenharmony_ci * limitations under the License.
141c1b0f19Sopenharmony_ci */
151c1b0f19Sopenharmony_ci
161c1b0f19Sopenharmony_ci#ifndef OHOS_DATA_BUFFER_H
171c1b0f19Sopenharmony_ci#define OHOS_DATA_BUFFER_H
181c1b0f19Sopenharmony_ci
191c1b0f19Sopenharmony_ci#include <map>
201c1b0f19Sopenharmony_ci#include <string>
211c1b0f19Sopenharmony_ci#include <cstddef>
221c1b0f19Sopenharmony_ci#include <cstdint>
231c1b0f19Sopenharmony_ci#include "ifeedable_data.h"
241c1b0f19Sopenharmony_ci#include "dcamera_frame_info.h"
251c1b0f19Sopenharmony_ci
261c1b0f19Sopenharmony_cinamespace OHOS {
271c1b0f19Sopenharmony_cinamespace DistributedHardware {
281c1b0f19Sopenharmony_ciclass DataBuffer : public IFeedableData {
291c1b0f19Sopenharmony_cipublic:
301c1b0f19Sopenharmony_ci    explicit DataBuffer(size_t capacity);
311c1b0f19Sopenharmony_ci
321c1b0f19Sopenharmony_ci    size_t Size() const;
331c1b0f19Sopenharmony_ci    size_t Offset() const;
341c1b0f19Sopenharmony_ci    size_t Capacity() const;
351c1b0f19Sopenharmony_ci    uint8_t *Data() const;
361c1b0f19Sopenharmony_ci    int32_t SetRange(size_t offset, size_t size);
371c1b0f19Sopenharmony_ci
381c1b0f19Sopenharmony_ci    void SetInt32(const std::string name, int32_t value);
391c1b0f19Sopenharmony_ci    void SetInt64(const std::string name, int64_t value);
401c1b0f19Sopenharmony_ci    void SetString(const std::string name, std::string value);
411c1b0f19Sopenharmony_ci    bool FindInt32(const std::string& name, int32_t& value);
421c1b0f19Sopenharmony_ci    bool FindInt64(const std::string& name, int64_t& value);
431c1b0f19Sopenharmony_ci    bool FindString(const std::string& name, std::string& value);
441c1b0f19Sopenharmony_ci    int64_t GetTimeStamp() override;
451c1b0f19Sopenharmony_ci    virtual ~DataBuffer();
461c1b0f19Sopenharmony_ci    DCameraFrameInfo frameInfo_;
471c1b0f19Sopenharmony_ci
481c1b0f19Sopenharmony_ciprivate:
491c1b0f19Sopenharmony_ci    size_t capacity_ = 0;
501c1b0f19Sopenharmony_ci    size_t rangeOffset_ = 0;
511c1b0f19Sopenharmony_ci    size_t rangeLength_ = 0;
521c1b0f19Sopenharmony_ci    uint8_t *data_ = nullptr;
531c1b0f19Sopenharmony_ci
541c1b0f19Sopenharmony_ci    std::map<std::string, int32_t> int32Map_;
551c1b0f19Sopenharmony_ci    std::map<std::string, int64_t> int64Map_;
561c1b0f19Sopenharmony_ci    std::map<std::string, std::string> stringMap_;
571c1b0f19Sopenharmony_ci
581c1b0f19Sopenharmony_ci    DataBuffer(const DataBuffer &) = delete;
591c1b0f19Sopenharmony_ci    DataBuffer &operator = (const DataBuffer &) = delete;
601c1b0f19Sopenharmony_ci};
611c1b0f19Sopenharmony_ci} // namespace DistributedHardware
621c1b0f19Sopenharmony_ci} // namespace OHOS
631c1b0f19Sopenharmony_ci#endif // OHOS_DATA_BUFFER_H
64