• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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 MEDIA_AVCODEC_AVSOURCE_H
17 #define MEDIA_AVCODEC_AVSOURCE_H
18 
19 #include <vector>
20 #include <memory>
21 #include <string>
22 #include "meta/format.h"
23 #include "media_demuxer.h"
24 
25 namespace OHOS {
26 namespace MediaAVCodec {
27 class AVSource {
28 public:
29     virtual ~AVSource() = default;
30 
31     /**
32      * @brief Get the format info of source.
33      * @param format The Format handle pointer to get format info.
34      * @return Returns {@link AVCS_ERR_OK} if success; returns an error code otherwise.
35      * @since 4.0
36      */
37     virtual int32_t GetSourceFormat(OHOS::Media::Format &format) = 0;
38 
39     /**
40      * @brief Gets the parameters of the source.
41      * @param format The Format handle pointer to get format info.
42      * @param trackIndex The track index to get format.
43      * @return Returns {@link AVCS_ERR_OK} if success; returns an error code otherwise.
44      * @since 4.0
45      */
46     virtual int32_t GetTrackFormat(OHOS::Media::Format &format, uint32_t trackIndex) = 0;
47 
48     /**
49      * @brief Gets the user meta for media.
50      * @param format The Format handle pointer to get format info.
51      * @return Returns {@link AVCS_ERR_OK} if success; returns an error code otherwise.
52      * @since 5.0
53      */
54     virtual int32_t GetUserMeta(OHOS::Media::Format &format) = 0;
55 
56     std::string sourceUri;
57     std::shared_ptr<Media::MediaDemuxer> mediaDemuxer = nullptr;
58 };
59 
60 class __attribute__((visibility("default"))) AVSourceFactory {
61 public:
62     static std::shared_ptr<AVSource> CreateWithURI(const std::string &uri);
63 
CreateWithFD(int32_t fd,int64_t offset,int64_t size)64     static std::shared_ptr<AVSource> CreateWithFD(int32_t fd, int64_t offset, int64_t size)
65     {
66         return nullptr;
67     }
68 
CreateWithDataSource(const std::shared_ptr<Media::IMediaDataSource> & dataSource)69     static std::shared_ptr<AVSource> CreateWithDataSource(const std::shared_ptr<Media::IMediaDataSource> &dataSource)
70     {
71         return nullptr;
72     }
73 private:
74     AVSourceFactory() = default;
75     ~AVSourceFactory() = default;
76 };
77 } // namespace MediaAVCodec
78 } // namespace OHOS
79 #endif // MEDIA_AVCODEC_AVSOURCE_H
80 
81