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