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 2024 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 : #ifndef FIREBOLT_RIALTO_SERVER_CAPS_BUILDER_H_
21 : #define FIREBOLT_RIALTO_SERVER_CAPS_BUILDER_H_
22 :
23 : #include "IGlibWrapper.h"
24 : #include "IGstWrapper.h"
25 : #include "IMediaPipeline.h"
26 : #include <gst/gst.h>
27 : #include <memory>
28 :
29 : namespace firebolt::rialto::server
30 : {
31 : class MediaSourceCapsBuilder
32 : {
33 : public:
34 : MediaSourceCapsBuilder(std::shared_ptr<firebolt::rialto::wrappers::IGstWrapper> gstWrapper,
35 : std::shared_ptr<firebolt::rialto::wrappers::IGlibWrapper> glibWrapper,
36 : const firebolt::rialto::IMediaPipeline::MediaSourceAV &source);
37 17 : virtual ~MediaSourceCapsBuilder() = default;
38 : virtual GstCaps *buildCaps();
39 :
40 : protected:
41 : std::shared_ptr<firebolt::rialto::wrappers::IGstWrapper> m_gstWrapper;
42 : std::shared_ptr<firebolt::rialto::wrappers::IGlibWrapper> m_glibWrapper;
43 : const IMediaPipeline::MediaSourceAV &m_attachedSource;
44 :
45 : GstCaps *buildCommonCaps();
46 : void addAlignmentToCaps(GstCaps *caps) const;
47 : void addCodecDataToCaps(GstCaps *caps) const;
48 : void addStreamFormatToCaps(GstCaps *caps) const;
49 : };
50 :
51 : class MediaSourceAudioCapsBuilder : public MediaSourceCapsBuilder
52 : {
53 : public:
54 : MediaSourceAudioCapsBuilder(std::shared_ptr<firebolt::rialto::wrappers::IGstWrapper> gstWrapper,
55 : std::shared_ptr<firebolt::rialto::wrappers::IGlibWrapper> glibWrapper,
56 : const IMediaPipeline::MediaSourceAudio &source);
57 20 : ~MediaSourceAudioCapsBuilder() override = default;
58 : GstCaps *buildCaps() override;
59 :
60 : protected:
61 : GstCaps *createOpusCaps();
62 : GstCaps *getAudioSpecificConfiguration() const;
63 : void addSampleRateAndChannelsToCaps(GstCaps *caps) const;
64 : void addMpegVersionToCaps(GstCaps *caps) const;
65 : void addRawAudioData(GstCaps *caps) const;
66 : void addFlacSpecificData(GstCaps *caps) const;
67 :
68 : const IMediaPipeline::MediaSourceAudio &m_attachedAudioSource;
69 : };
70 :
71 : class MediaSourceVideoCapsBuilder : public MediaSourceCapsBuilder
72 : {
73 : public:
74 : MediaSourceVideoCapsBuilder(std::shared_ptr<firebolt::rialto::wrappers::IGstWrapper> gstWrapper,
75 : std::shared_ptr<firebolt::rialto::wrappers::IGlibWrapper> glibWrapper,
76 : const IMediaPipeline::MediaSourceVideo &source);
77 13 : ~MediaSourceVideoCapsBuilder() override = default;
78 : GstCaps *buildCaps() override;
79 :
80 : protected:
81 : const IMediaPipeline::MediaSourceVideo &m_attachedVideoSource;
82 : };
83 :
84 : class MediaSourceVideoDolbyVisionCapsBuilder : public MediaSourceVideoCapsBuilder
85 : {
86 : public:
87 : MediaSourceVideoDolbyVisionCapsBuilder(std::shared_ptr<firebolt::rialto::wrappers::IGstWrapper> gstWrapper,
88 : std::shared_ptr<firebolt::rialto::wrappers::IGlibWrapper> glibWrapper,
89 : const IMediaPipeline::MediaSourceVideoDolbyVision &source);
90 2 : ~MediaSourceVideoDolbyVisionCapsBuilder() override = default;
91 : GstCaps *buildCaps() override;
92 :
93 : protected:
94 : const IMediaPipeline::MediaSourceVideoDolbyVision &m_attachedDolbySource;
95 : };
96 : } // namespace firebolt::rialto::server
97 :
98 : #endif // FIREBOLT_RIALTO_SERVER_CAPS_BUILDER_H_
|