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 18 : 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 22 : ~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 addMpegVersion4ToCaps(GstCaps *caps) const;
65 : void addMp3Caps(GstCaps *caps) const;
66 : void addRawAudioData(GstCaps *caps) const;
67 : void addFlacSpecificData(GstCaps *caps) const;
68 :
69 : const IMediaPipeline::MediaSourceAudio &m_attachedAudioSource;
70 : };
71 :
72 : class MediaSourceVideoCapsBuilder : public MediaSourceCapsBuilder
73 : {
74 : public:
75 : MediaSourceVideoCapsBuilder(std::shared_ptr<firebolt::rialto::wrappers::IGstWrapper> gstWrapper,
76 : std::shared_ptr<firebolt::rialto::wrappers::IGlibWrapper> glibWrapper,
77 : const IMediaPipeline::MediaSourceVideo &source);
78 13 : ~MediaSourceVideoCapsBuilder() override = default;
79 : GstCaps *buildCaps() override;
80 :
81 : protected:
82 : const IMediaPipeline::MediaSourceVideo &m_attachedVideoSource;
83 : };
84 :
85 : class MediaSourceVideoDolbyVisionCapsBuilder : public MediaSourceVideoCapsBuilder
86 : {
87 : public:
88 : MediaSourceVideoDolbyVisionCapsBuilder(std::shared_ptr<firebolt::rialto::wrappers::IGstWrapper> gstWrapper,
89 : std::shared_ptr<firebolt::rialto::wrappers::IGlibWrapper> glibWrapper,
90 : const IMediaPipeline::MediaSourceVideoDolbyVision &source);
91 2 : ~MediaSourceVideoDolbyVisionCapsBuilder() override = default;
92 : GstCaps *buildCaps() override;
93 :
94 : protected:
95 : const IMediaPipeline::MediaSourceVideoDolbyVision &m_attachedDolbySource;
96 : };
97 : } // namespace firebolt::rialto::server
98 :
99 : #endif // FIREBOLT_RIALTO_SERVER_CAPS_BUILDER_H_
|