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 "MediaPipelineCapabilities.h"
23 : #include "RialtoServerLogging.h"
24 : #include <MediaCommon.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_SERVER_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 : mediaPipelineCapabilities =
50 1 : std::make_unique<server::MediaPipelineCapabilities>(server::IGstCapabilitiesFactory::getFactory());
51 : }
52 0 : catch (const std::exception &e)
53 : {
54 0 : RIALTO_SERVER_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::server
63 : {
64 6 : MediaPipelineCapabilities::MediaPipelineCapabilities(const std::shared_ptr<IGstCapabilitiesFactory> &gstCapabilitiesFactory)
65 6 : : m_kGstCapabilitiesFactory{gstCapabilitiesFactory}
66 : {
67 6 : RIALTO_SERVER_LOG_DEBUG("entry:");
68 : // Create GstCapabilities immediately in constructor.
69 : // Note: preloaded capabilities are managed by MediaPipelineService (setPreloadedCapabilities) and are independent
70 : // of MediaPipelineCapabilities construction.
71 6 : m_gstCapabilities = m_kGstCapabilitiesFactory->createGstCapabilities();
72 6 : if (!m_gstCapabilities)
73 : {
74 1 : RIALTO_SERVER_LOG_ERROR("Gstreamer capabilities could not be created");
75 1 : throw std::runtime_error("Gstreamer capabilities could not be created");
76 : }
77 8 : }
78 :
79 15 : MediaPipelineCapabilities::~MediaPipelineCapabilities()
80 : {
81 5 : RIALTO_SERVER_LOG_DEBUG("entry:");
82 10 : }
83 :
84 1 : std::vector<std::string> MediaPipelineCapabilities::getSupportedMimeTypes(MediaSourceType sourceType)
85 : {
86 1 : return m_gstCapabilities->getSupportedMimeTypes(sourceType);
87 : }
88 :
89 1 : bool MediaPipelineCapabilities::isMimeTypeSupported(const std::string &mimeType)
90 : {
91 1 : return m_gstCapabilities->isMimeTypeSupported(mimeType);
92 : }
93 :
94 1 : std::vector<std::string> MediaPipelineCapabilities::getSupportedProperties(MediaSourceType mediaType,
95 : const std::vector<std::string> &propertyNames)
96 : {
97 1 : return m_gstCapabilities->getSupportedProperties(mediaType, propertyNames);
98 : }
99 :
100 1 : bool MediaPipelineCapabilities::isVideoMaster(bool &isVideoMaster)
101 : {
102 1 : return m_gstCapabilities->isVideoMaster(isVideoMaster);
103 : }
104 :
105 : }; // namespace firebolt::rialto::server
|