• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023-2025 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_MOCK_H
17 #define DEMUXER_MOCK_H
18 
19 #include <cinttypes>
20 #include <string>
21 #include <memory>
22 #include "nocopyable.h"
23 #include "avformat_mock.h"
24 #include "avsource_mock.h"
25 #include "common_mock.h"
26 #include "av_common.h"
27 #include "avcodec_common.h"
28 
29 namespace OHOS {
30 namespace MediaAVCodec {
31 class DemuxerMock : public NoCopyable {
32 public:
33     virtual ~DemuxerMock() = default;
34 
35     virtual int32_t Destroy() = 0;
36     virtual int32_t SelectTrackByID(uint32_t trackIndex) = 0;
37     virtual int32_t UnselectTrackByID(uint32_t trackIndex) = 0;
38     virtual int32_t ReadSample(uint32_t trackIndex, std::shared_ptr<AVMemoryMock> sample,
39         AVCodecBufferInfo *bufferInfo, uint32_t &flag, bool checkBufferInfo = false) = 0;
40     virtual int32_t SeekToTime(int64_t mSeconds, Media::SeekMode mode) = 0;
SetMediaKeySystemInfoCallback(bool isNull)41     virtual int32_t SetMediaKeySystemInfoCallback(bool isNull)
42     {
43         return AV_ERR_OK;
44     }
SetDemuxerMediaKeySystemInfoCallback(bool isNull)45     virtual int32_t SetDemuxerMediaKeySystemInfoCallback(bool isNull)
46     {
47         return AV_ERR_OK;
48     }
GetMediaKeySystemInfo()49     virtual int32_t GetMediaKeySystemInfo()
50     {
51         return AV_ERR_OK;
52     }
53     virtual int32_t GetIndexByRelativePresentationTimeUs(const uint32_t trackIndex,
54         const uint64_t relativePresentationTimeUs, uint32_t &index) = 0;
55     virtual int32_t GetRelativePresentationTimeUsByIndex(const uint32_t trackIndex,
56         const uint32_t index, uint64_t &relativePresentationTimeUs) = 0;
GetCurrentCacheSize(uint32_t trackId,uint32_t & size)57     virtual int32_t GetCurrentCacheSize(uint32_t trackId, uint32_t& size)
58     {
59         return AV_ERR_OK;
60     }
61 };
62 
63 class __attribute__((visibility("default"))) AVDemuxerMockFactory {
64 public:
65     static std::shared_ptr<DemuxerMock> CreateDemuxer(std::shared_ptr<AVSourceMock> source);
66 private:
67     AVDemuxerMockFactory() = delete;
68     ~AVDemuxerMockFactory() = delete;
69 };
70 }  // namespace MediaAVCodec
71 }  // namespace OHOS
72 #endif // DEMUXER_MOCK_H