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 #include "media_source.h"
17 #include <type_traits>
18 namespace OHOS {
19 namespace Media {
20 namespace Plugin {
MediaSource(std::string uri)21 MediaSource::MediaSource(std::string uri)
22 : uri_(std::move(uri)), type_(SourceType::SOURCE_TYPE_URI)
23 {
24 }
25
MediaSource(std::shared_ptr<DataConsumer> dataStream)26 MediaSource::MediaSource(std::shared_ptr<DataConsumer> dataStream)
27 : type_(SourceType::SOURCE_TYPE_STREAM), dataConsumer_(std::move(dataStream))
28 {
29 }
30
31 #ifndef OHOS_LITE
MediaSource(std::shared_ptr<IMediaDataSource> dataSrc)32 MediaSource::MediaSource(std::shared_ptr<IMediaDataSource> dataSrc)
33 :type_(SourceType::SOURCE_TYPE_STREAM), dataSrc_(std::move(dataSrc))
34 {
35 }
36 #endif
37
MediaSource(std::string uri,std::map<std::string,std::string> header)38 MediaSource::MediaSource(std::string uri, std::map<std::string, std::string> header)
39 : uri_(std::move(uri)), header_(std::move(header))
40 {
41 }
42
GetSourceType() const43 SourceType MediaSource::GetSourceType() const
44 {
45 return type_;
46 }
47
GetSourceUri() const48 const std::string &MediaSource::GetSourceUri() const
49 {
50 return uri_;
51 }
52
GetSourceHeader() const53 const std::map<std::string, std::string> &MediaSource::GetSourceHeader() const
54 {
55 return header_;
56 }
57
GetDataConsumer() const58 std::shared_ptr<DataConsumer> MediaSource::GetDataConsumer() const
59 {
60 return dataConsumer_;
61 }
62
63 #ifndef OHOS_LITE
GetDataSrc() const64 std::shared_ptr<IMediaDataSource> MediaSource::GetDataSrc() const
65 {
66 return dataSrc_;
67 }
68 #endif
69 } // namespace Plugin
70 } // namespace Media
71 } // namespace OHOS
72
73