Debian Codegraph @

src/videofilters/h26x/h264-nal-packer.h

raw symbols SCIP
1 /*
2 * Copyright (c) 2010-2022 Belledonne Communications SARL.
3 *
4 * This file is part of mediastreamer2
5 * (see https://gitlab.linphone.org/BC/public/mediastreamer2).
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
16 *
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #pragma once
22
23 #include "nal-packer.h"
24
25 namespace mediastreamer {
26
27 class H264NalPacker : public NalPacker {
28 public:
29 enum PacketizationMode { SingleNalUnitMode, NonInterleavedMode };
30
31 H264NalPacker(size_t maxPayloadSize)
32 : NalPacker(new NaluAggregator(maxPayloadSize), new NaluSpliter(maxPayloadSize), maxPayloadSize) {
33 }
34
35 private:
36 class NaluAggregator : public NaluAggregatorInterface {
37 public:
38 using NaluAggregatorInterface::NaluAggregatorInterface;
39 ~NaluAggregator() override {
40 reset();
41 }
42
43 mblk_t *feed(mblk_t *nalu) override;
44 bool isAggregating() const override {
45 return _stap != nullptr;
46 }
47 void reset() override;
48 mblk_t *completeAggregation() override;
49
50 private:
51 static mblk_t *concatNalus(mblk_t *m1, mblk_t *m2);
52 static mblk_t *prependStapA(mblk_t *m);
53 static void putNalSize(mblk_t *m, size_t sz);
54
55 mblk_t *_stap = nullptr;
56 size_t _size = 0;
57 };
58
59 class NaluSpliter : public NaluSpliterInterface {
60 public:
61 using NaluSpliterInterface::NaluSpliterInterface;
62 void feed(mblk_t *nalu) override;
63 };
64 };
65
66 } // namespace mediastreamer