1da853ecaSopenharmony_ci/*
2da853ecaSopenharmony_ci * Copyright (C) 2023 Huawei Device Co., Ltd.
3da853ecaSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4da853ecaSopenharmony_ci * you may not use this file except in compliance with the License.
5da853ecaSopenharmony_ci * You may obtain a copy of the License at
6da853ecaSopenharmony_ci *
7da853ecaSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8da853ecaSopenharmony_ci *
9da853ecaSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10da853ecaSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11da853ecaSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12da853ecaSopenharmony_ci * See the License for the specific language governing permissions and
13da853ecaSopenharmony_ci * limitations under the License.
14da853ecaSopenharmony_ci */
15da853ecaSopenharmony_ci
16da853ecaSopenharmony_ci#ifndef AVDEMUXER_IMPL_H
17da853ecaSopenharmony_ci#define AVDEMUXER_IMPL_H
18da853ecaSopenharmony_ci
19da853ecaSopenharmony_ci#include <memory>
20da853ecaSopenharmony_ci#include "avdemuxer.h"
21da853ecaSopenharmony_ci#include "avsource.h"
22da853ecaSopenharmony_ci#include "nocopyable.h"
23da853ecaSopenharmony_ci#include "media_demuxer.h"
24da853ecaSopenharmony_ci
25da853ecaSopenharmony_cinamespace OHOS {
26da853ecaSopenharmony_cinamespace MediaAVCodec {
27da853ecaSopenharmony_ciusing namespace Media;
28da853ecaSopenharmony_ciclass AVDemuxerImpl : public AVDemuxer, public NoCopyable {
29da853ecaSopenharmony_cipublic:
30da853ecaSopenharmony_ci    AVDemuxerImpl();
31da853ecaSopenharmony_ci    ~AVDemuxerImpl();
32da853ecaSopenharmony_ci
33da853ecaSopenharmony_ci    int32_t SelectTrackByID(uint32_t trackIndex) override;
34da853ecaSopenharmony_ci    int32_t UnselectTrackByID(uint32_t trackIndex) override;
35da853ecaSopenharmony_ci    int32_t ReadSample(uint32_t trackIndex, std::shared_ptr<AVSharedMemory> sample,
36da853ecaSopenharmony_ci        AVCodecBufferInfo &info, uint32_t &flag) override;
37da853ecaSopenharmony_ci    int32_t ReadSample(uint32_t trackIndex, std::shared_ptr<AVSharedMemory> sample,
38da853ecaSopenharmony_ci        AVCodecBufferInfo &info, AVCodecBufferFlag &flag) override;
39da853ecaSopenharmony_ci    int32_t ReadSampleBuffer(uint32_t trackIndex, std::shared_ptr<AVBuffer> sample) override;
40da853ecaSopenharmony_ci    int32_t SeekToTime(int64_t millisecond, const SeekMode mode) override;
41da853ecaSopenharmony_ci    int32_t SetCallback(const std::shared_ptr<AVDemuxerCallback> &callback) override;
42da853ecaSopenharmony_ci    int32_t GetMediaKeySystemInfo(std::multimap<std::string, std::vector<uint8_t>> &infos) override;
43da853ecaSopenharmony_ci    int32_t Init(std::shared_ptr<AVSource> source);
44da853ecaSopenharmony_ci    int32_t StartReferenceParser(int64_t startTimeMs) override;
45da853ecaSopenharmony_ci    int32_t GetFrameLayerInfo(std::shared_ptr<AVBuffer> videoSample, FrameLayerInfo &frameLayerInfo) override;
46da853ecaSopenharmony_ci    int32_t GetGopLayerInfo(uint32_t gopId, GopLayerInfo &gopLayerInfo) override;
47da853ecaSopenharmony_ci
48da853ecaSopenharmony_ci    int32_t GetIndexByRelativePresentationTimeUs(const uint32_t trackIndex,
49da853ecaSopenharmony_ci        const uint64_t relativePresentationTimeUs, uint32_t &index) override;
50da853ecaSopenharmony_ci    int32_t GetRelativePresentationTimeUsByIndex(const uint32_t trackIndex,
51da853ecaSopenharmony_ci        const uint32_t index, uint64_t &relativePresentationTimeUs) override;
52da853ecaSopenharmony_ciprivate:
53da853ecaSopenharmony_ci    std::shared_ptr<MediaDemuxer> mediaDemuxer_ = nullptr;
54da853ecaSopenharmony_ci    std::string sourceUri_;
55da853ecaSopenharmony_ci};
56da853ecaSopenharmony_ci} // namespace MediaAVCodec
57da853ecaSopenharmony_ci} // namespace OHOS
58da853ecaSopenharmony_ci#endif // AVDEMUXER_IMPL_H