• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-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 #ifndef OHOS_CAMERA_DPS_READER_H
16 #define OHOS_CAMERA_DPS_READER_H
17 
18 #include "basic_definitions.h"
19 #include "demuxer.h"
20 #include "track.h"
21 #include "media_format.h"
22 
23 namespace OHOS {
24 namespace CameraStandard {
25 namespace DeferredProcessing {
26 using namespace MediaAVCodec;
27 class Reader {
28 public:
29     Reader() = default;
30     virtual ~Reader();
31 
32     MediaManagerError Create(int32_t inputFd);
33     MediaManagerError Read(TrackType trackType, std::shared_ptr<AVBuffer>& sample);
34     MediaManagerError GetMediaInfo(std::shared_ptr<MediaInfo>& mediaInfo);
35     MediaManagerError Reset(int64_t resetPts);
36 
GetTracks()37     inline const std::map<TrackType, const std::shared_ptr<Track>>& GetTracks() const
38     {
39         return tracks_;
40     };
41 
42 private:
43     MediaManagerError GetSourceFormat();
44     void GetSourceMediaInfo(std::shared_ptr<MediaInfo>& mediaInfo) const;
45     MediaManagerError GetTrackMediaInfo(const TrackFormat& trackFormat, std::shared_ptr<MediaInfo>& mediaInfo) const;
46     MediaManagerError InitTracksAndDemuxer();
47     static int32_t FixFPS(const double fps);
48 
49 private:
50     std::shared_ptr<AVSource> source_ {nullptr};
51     std::shared_ptr<Format> sourceFormat_ {nullptr};
52     std::shared_ptr<Format> userFormat_ {nullptr};
53     std::shared_ptr<Demuxer> inputDemuxer_ {nullptr};
54     int32_t trackCount_ {0};
55     std::map<TrackType, const std::shared_ptr<Track>> tracks_ {};
56 };
57 } // namespace DeferredProcessing
58 } // namespace CameraStandard
59 } // namespace OHOS
60 #endif // OHOS_CAMERA_DPS_READER_H