Line data Source code
1 : /*
2 : * If not stated otherwise in this file or this component's LICENSE file the
3 : * following copyright and licenses apply:
4 : *
5 : * Copyright 2022 Sky UK
6 : *
7 : * Licensed under the Apache License, Version 2.0 (the "License");
8 : * you may not use this file except in compliance with the License.
9 : * You may obtain a copy of the License at
10 : *
11 : * http://www.apache.org/licenses/LICENSE-2.0
12 : *
13 : * Unless required by applicable law or agreed to in writing, software
14 : * distributed under the License is distributed on an "AS IS" BASIS,
15 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 : * See the License for the specific language governing permissions and
17 : * limitations under the License.
18 : */
19 :
20 : #include <stdexcept>
21 :
22 : #include "IMediaPipelineCapabilitiesIpcFactory.h"
23 : #include "MediaPipelineCapabilities.h"
24 : #include "RialtoClientLogging.h"
25 :
26 : namespace firebolt::rialto
27 : {
28 1 : std::shared_ptr<IMediaPipelineCapabilitiesFactory> IMediaPipelineCapabilitiesFactory::createFactory()
29 : {
30 1 : std::shared_ptr<IMediaPipelineCapabilitiesFactory> factory;
31 :
32 : try
33 : {
34 1 : factory = std::make_shared<MediaPipelineCapabilitiesFactory>();
35 : }
36 0 : catch (const std::exception &e)
37 : {
38 0 : RIALTO_CLIENT_LOG_ERROR("Failed to create the media pipeline capabilities factory, reason: %s", e.what());
39 : }
40 :
41 1 : return factory;
42 : }
43 :
44 1 : std::unique_ptr<IMediaPipelineCapabilities> MediaPipelineCapabilitiesFactory::createMediaPipelineCapabilities() const
45 : {
46 1 : std::unique_ptr<IMediaPipelineCapabilities> mediaPipelineCapabilities;
47 : try
48 : {
49 1 : mediaPipelineCapabilities = std::make_unique<client::MediaPipelineCapabilities>(
50 3 : client::IMediaPipelineCapabilitiesIpcFactory::createFactory());
51 : }
52 1 : catch (const std::exception &e)
53 : {
54 1 : RIALTO_CLIENT_LOG_ERROR("Failed to create the media pipeline capabilities, reason: %s", e.what());
55 : }
56 :
57 1 : return mediaPipelineCapabilities;
58 : }
59 :
60 : }; // namespace firebolt::rialto
61 :
62 : namespace firebolt::rialto::client
63 : {
64 6 : MediaPipelineCapabilities::MediaPipelineCapabilities(
65 6 : const std::shared_ptr<IMediaPipelineCapabilitiesIpcFactory> &MediaPipelineCapabilitiesIpcFactory)
66 : {
67 6 : RIALTO_CLIENT_LOG_DEBUG("entry:");
68 :
69 6 : m_mediaPipelineCapabilitiesIpc = MediaPipelineCapabilitiesIpcFactory->createMediaPipelineCapabilitiesIpc();
70 6 : if (!m_mediaPipelineCapabilitiesIpc)
71 : {
72 2 : throw std::runtime_error("Media pipeline capabilities ipc could not be created");
73 : }
74 8 : }
75 :
76 4 : MediaPipelineCapabilities::~MediaPipelineCapabilities()
77 : {
78 4 : RIALTO_CLIENT_LOG_DEBUG("entry:");
79 :
80 4 : m_mediaPipelineCapabilitiesIpc.reset();
81 : }
82 :
83 1 : std::vector<std::string> MediaPipelineCapabilities::getSupportedMimeTypes(MediaSourceType sourceType)
84 : {
85 1 : RIALTO_CLIENT_LOG_DEBUG("entry:");
86 :
87 1 : return m_mediaPipelineCapabilitiesIpc->getSupportedMimeTypes(sourceType);
88 : }
89 :
90 1 : bool MediaPipelineCapabilities::isMimeTypeSupported(const std::string &mimeType)
91 : {
92 1 : RIALTO_CLIENT_LOG_DEBUG("entry:");
93 :
94 1 : return m_mediaPipelineCapabilitiesIpc->isMimeTypeSupported(mimeType);
95 : }
96 :
97 1 : std::vector<std::string> MediaPipelineCapabilities::getSupportedProperties(MediaSourceType mediaType,
98 : const std::vector<std::string> &propertyNames)
99 : {
100 1 : RIALTO_CLIENT_LOG_DEBUG("entry:");
101 :
102 1 : return m_mediaPipelineCapabilitiesIpc->getSupportedProperties(mediaType, propertyNames);
103 : }
104 :
105 : }; // namespace firebolt::rialto::client
|