• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2021 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 HISTREAMER_PLUGIN_MEDIA_SOURCE_H
17 #define HISTREAMER_PLUGIN_MEDIA_SOURCE_H
18 
19 #include <map>
20 #include <memory>
21 #include "plugin/common/plugin_buffer.h"
22 #include "plugin/common/plugin_types.h" // NOLINT: used it
23 #include "data_stream.h"
24 
25 namespace OHOS {
26 namespace Media {
27 namespace Plugin {
28 /**
29  * @brief Unified enumerates media source types.
30  *
31  * @since 1.0
32  * @version 1.0
33  */
34 enum class SourceType : int32_t {
35     /** Local file path or network address */
36     SOURCE_TYPE_URI = 0,
37     /** Local file descriptor */
38     SOURCE_TYPE_FD,
39     /** Stream data */
40     SOURCE_TYPE_STREAM,
41 };
42 
43 class MediaSource {
44 public:
45     /// Construct an a specified URI.
46     explicit MediaSource(std::string uri);
47 
48     explicit MediaSource(std::shared_ptr<DataConsumer> dataStream);
49 
50     MediaSource(std::string uri, std::map<std::string, std::string> header);
51 
52     /// Destructor
53     virtual ~MediaSource() = default;
54 
55     /// Obtains the source type.
56     SourceType GetSourceType() const;
57 
58     /// Obtains the media source URI.
59     const std::string &GetSourceUri() const;
60 
61     const std::map<std::string, std::string> &GetSourceHeader() const;
62 
63     std::shared_ptr<DataConsumer> GetDataConsumer() const;
64 private:
65     std::string uri_ {};
66     SourceType type_ {};
67     std::map<std::string, std::string> header_ {};
68     std::shared_ptr<DataConsumer> dataConsumer_ {};
69 };
70 } // namespace Plugin
71 } // namespace Media
72 } // namespace OHOS
73 #endif