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