• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 AVMUXER_UTIL_H
17 #define AVMUXER_UTIL_H
18 
19 #include <functional>
20 #include <set>
21 #include <map>
22 #include <vector>
23 #include <gst/gst.h>
24 #include "i_avmuxer_engine.h"
25 #include "nocopyable.h"
26 #include "gst_shmem_wrap_allocator.h"
27 #include "av_common.h"
28 
29 namespace OHOS {
30 namespace Media {
31 struct TrackInfo {
32     bool hasCodecData_ = false;
33     bool needData_ = true;
34     GstCaps *caps_ = nullptr;
35     GstElement *src_ = nullptr;
36     std::string mimeType_;
37 };
38 
39 struct FormatParam {
40     int32_t width = 0;
41     int32_t height = 0;
42     int32_t frameRate = 0;
43     int32_t channels = 0;
44     int32_t rate = 0;
45 };
46 
47 class AVMuxerUtil {
48 public:
49     AVMuxerUtil() = delete;
50     ~AVMuxerUtil() = delete;
51 
52     static bool SetCaps(const MediaDescription &trackDesc, const std::string &mimeType,
53         GstCaps **src_caps);
54     static std::vector<std::string> FindFormat();
55     static bool FindMux(const std::string &format, std::string &mux);
56     static bool FindMimeTypes(const std::string &format, std::set<std::string> &mimeTypes);
57     static bool FindInnerTypes(const std::string &mimeType, std::string &innerType);
58     static bool FindParse(const std::string &mimeType, std::string &parse);
59     static bool FindMediaType(const std::string &mimeType, MediaType &mediaType);
60 };
61 }  // namespace Media
62 }  // namespace OHOS
63 #endif  // AVMUXER_UTIL_H