1 /*
2  * Copyright (C) 2023 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 DEMUXER_INNER_MOCK_H
17 #define DEMUXER_INNER_MOCK_H
18 
19 #include "demuxer_mock.h"
20 #include "common_mock.h"
21 #include "avformat_inner_mock.h"
22 #include "avdemuxer.h"
23 
24 namespace OHOS {
25 namespace MediaAVCodec {
26 class DemuxerInnerMock : public DemuxerMock {
27 public:
DemuxerInnerMock(std::shared_ptr<AVDemuxer> demuxer)28     explicit DemuxerInnerMock(std::shared_ptr<AVDemuxer> demuxer) : demuxer_(demuxer) {}
29     ~DemuxerInnerMock() = default;
30     int32_t Destroy() override;
31     int32_t SelectTrackByID(uint32_t trackIndex) override;
32     int32_t UnselectTrackByID(uint32_t trackIndex) override;
33     int32_t ReadSample(uint32_t trackIndex, std::shared_ptr<AVMemoryMock> sample,
34         AVCodecBufferInfo *bufferInfo, uint32_t &flag, bool checkBufferInfo) override;
35     int32_t SeekToTime(int64_t mSeconds, SeekMode mode) override;
36     int32_t GetIndexByRelativePresentationTimeUs(const uint32_t trackIndex,
37         const uint64_t relativePresentationTimeUs, uint32_t &index) override;
38     int32_t GetRelativePresentationTimeUsByIndex(const uint32_t trackIndex,
39         const uint32_t index, uint64_t &relativePresentationTimeUs) override;
40 
41 private:
42     std::shared_ptr<AVDemuxer> demuxer_ = nullptr;
43 };
44 } // namespace MediaAVCodec
45 } // namespace OHOS
46 #endif // DEMUXER_INNER_MOCK_H