1fa7767c5Sopenharmony_ci/*
2fa7767c5Sopenharmony_ci * Copyright (c) 2021-2021 Huawei Device Co., Ltd.
3fa7767c5Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4fa7767c5Sopenharmony_ci * you may not use this file except in compliance with the License.
5fa7767c5Sopenharmony_ci * You may obtain a copy of the License at
6fa7767c5Sopenharmony_ci *
7fa7767c5Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8fa7767c5Sopenharmony_ci *
9fa7767c5Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10fa7767c5Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11fa7767c5Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12fa7767c5Sopenharmony_ci * See the License for the specific language governing permissions and
13fa7767c5Sopenharmony_ci * limitations under the License.
14fa7767c5Sopenharmony_ci */
15fa7767c5Sopenharmony_ci
16fa7767c5Sopenharmony_ci#ifndef HISTREAMER_PLUGIN_MEDIA_SOURCE_H
17fa7767c5Sopenharmony_ci#define HISTREAMER_PLUGIN_MEDIA_SOURCE_H
18fa7767c5Sopenharmony_ci
19fa7767c5Sopenharmony_ci#include <map>
20fa7767c5Sopenharmony_ci#include <memory>
21fa7767c5Sopenharmony_ci#include "plugin/common/plugin_buffer.h"
22fa7767c5Sopenharmony_ci#include "plugin/common/plugin_types.h" // NOLINT: used it
23fa7767c5Sopenharmony_ci#include "data_stream.h"
24fa7767c5Sopenharmony_ci
25fa7767c5Sopenharmony_cinamespace OHOS {
26fa7767c5Sopenharmony_cinamespace Media {
27fa7767c5Sopenharmony_cinamespace Plugin {
28fa7767c5Sopenharmony_ci/**
29fa7767c5Sopenharmony_ci * @brief Unified enumerates media source types.
30fa7767c5Sopenharmony_ci *
31fa7767c5Sopenharmony_ci * @since 1.0
32fa7767c5Sopenharmony_ci * @version 1.0
33fa7767c5Sopenharmony_ci */
34fa7767c5Sopenharmony_cienum class SourceType : int32_t {
35fa7767c5Sopenharmony_ci    /** Local file path or network address */
36fa7767c5Sopenharmony_ci    SOURCE_TYPE_URI = 0,
37fa7767c5Sopenharmony_ci    /** Local file descriptor */
38fa7767c5Sopenharmony_ci    SOURCE_TYPE_FD,
39fa7767c5Sopenharmony_ci    /** Stream data */
40fa7767c5Sopenharmony_ci    SOURCE_TYPE_STREAM,
41fa7767c5Sopenharmony_ci};
42fa7767c5Sopenharmony_ci
43fa7767c5Sopenharmony_citypedef struct PlayStrategy {
44fa7767c5Sopenharmony_ci    uint32_t width {0};
45fa7767c5Sopenharmony_ci    uint32_t height {0};
46fa7767c5Sopenharmony_ci    uint32_t duration {0};
47fa7767c5Sopenharmony_ci    bool preferHDR {false};
48fa7767c5Sopenharmony_ci} PlayStrategy;
49fa7767c5Sopenharmony_ci
50fa7767c5Sopenharmony_ciclass MediaSource {
51fa7767c5Sopenharmony_cipublic:
52fa7767c5Sopenharmony_ci    /// Construct an a specified URI.
53fa7767c5Sopenharmony_ci    explicit MediaSource(std::string uri);
54fa7767c5Sopenharmony_ci
55fa7767c5Sopenharmony_ci    explicit MediaSource(std::shared_ptr<DataConsumer> dataStream);
56fa7767c5Sopenharmony_ci
57fa7767c5Sopenharmony_ci    MediaSource(std::string uri, std::map<std::string, std::string> header);
58fa7767c5Sopenharmony_ci
59fa7767c5Sopenharmony_ci    /// Destructor
60fa7767c5Sopenharmony_ci    virtual ~MediaSource() = default;
61fa7767c5Sopenharmony_ci
62fa7767c5Sopenharmony_ci    /// Obtains the source type.
63fa7767c5Sopenharmony_ci    SourceType GetSourceType() const;
64fa7767c5Sopenharmony_ci
65fa7767c5Sopenharmony_ci    /// Obtains the media source URI.
66fa7767c5Sopenharmony_ci    const std::string &GetSourceUri() const;
67fa7767c5Sopenharmony_ci
68fa7767c5Sopenharmony_ci    const std::map<std::string, std::string> &GetSourceHeader() const;
69fa7767c5Sopenharmony_ci
70fa7767c5Sopenharmony_ci    std::shared_ptr<DataConsumer> GetDataConsumer() const;
71fa7767c5Sopenharmony_ci
72fa7767c5Sopenharmony_ci    void SetPlayStrategy(const std::shared_ptr<PlayStrategy>& playStrategy);
73fa7767c5Sopenharmony_ci
74fa7767c5Sopenharmony_ci    std::shared_ptr<PlayStrategy> GetPlayStrategy() const;
75fa7767c5Sopenharmony_ciprivate:
76fa7767c5Sopenharmony_ci    std::string uri_ {};
77fa7767c5Sopenharmony_ci    SourceType type_ {};
78fa7767c5Sopenharmony_ci    std::map<std::string, std::string> header_ {};
79fa7767c5Sopenharmony_ci    std::shared_ptr<DataConsumer> dataConsumer_ {};
80fa7767c5Sopenharmony_ci};
81fa7767c5Sopenharmony_ci} // namespace Plugin
82fa7767c5Sopenharmony_ci} // namespace Media
83fa7767c5Sopenharmony_ci} // namespace OHOS
84fa7767c5Sopenharmony_ci#endif