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 : #ifndef FIREBOLT_RIALTO_COMMON_I_MEDIA_FRAME_WRITER_H_
21 : #define FIREBOLT_RIALTO_COMMON_I_MEDIA_FRAME_WRITER_H_
22 :
23 : #include <stdint.h>
24 :
25 : #include <memory>
26 : #include <string>
27 :
28 : #include "IMediaPipeline.h"
29 : #include <MediaCommon.h>
30 : #include <ShmCommon.h>
31 :
32 : namespace firebolt::rialto::common
33 : {
34 : class IMediaFrameWriter;
35 :
36 : /**
37 : * @brief IMediaFrameWriter factory class, returns a concrete implementation of IMediaFrameWriter
38 : */
39 : class IMediaFrameWriterFactory
40 : {
41 : public:
42 142 : IMediaFrameWriterFactory() = default;
43 142 : virtual ~IMediaFrameWriterFactory() = default;
44 :
45 : /**
46 : * @brief Gets the IMediaFrameWriterFactory instance.
47 : *
48 : * @retval the factory instance or null on error.
49 : */
50 : static std::shared_ptr<IMediaFrameWriterFactory> getFactory();
51 :
52 : /**
53 : * @brief Creates a IMediaFrameWriter object.
54 : *
55 : * @param[in] shmBuffer : The shared buffer pointer.
56 : * @param[in] shmInfo : The information for populating the shared memory.
57 : *
58 : * @retval the new media frame writer audio instance or null on error.
59 : */
60 : virtual std::unique_ptr<IMediaFrameWriter> createFrameWriter(uint8_t *shmBuffer,
61 : const std::shared_ptr<MediaPlayerShmInfo> &shminfo) = 0;
62 : };
63 :
64 : /**
65 : * @brief The definition of the IMediaFrameWriter interface.
66 : *
67 : * This interface defines the media frame writer APIs that are used to write data the shared memory.
68 : */
69 : class IMediaFrameWriter
70 : {
71 : public:
72 53 : IMediaFrameWriter() = default;
73 53 : virtual ~IMediaFrameWriter() = default;
74 :
75 : IMediaFrameWriter(const IMediaFrameWriter &) = delete;
76 : IMediaFrameWriter &operator=(const IMediaFrameWriter &) = delete;
77 : IMediaFrameWriter(IMediaFrameWriter &&) = delete;
78 : IMediaFrameWriter &operator=(IMediaFrameWriter &&) = delete;
79 :
80 : /**
81 : * @brief Write the frame data.
82 : *
83 : * @param[in] data : Media Segment data.
84 : *
85 : * @retval true on success.
86 : */
87 : virtual AddSegmentStatus writeFrame(const std::unique_ptr<IMediaPipeline::MediaSegment> &data) = 0;
88 :
89 : /**
90 : * @brief Gets number of written frames
91 : *
92 : * @retval number of written frames
93 : */
94 : virtual uint32_t getNumFrames() = 0;
95 : };
96 :
97 : }; // namespace firebolt::rialto::common
98 :
99 : #endif // FIREBOLT_RIALTO_COMMON_I_MEDIA_FRAME_WRITER_H_
|