| 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-unpacker.h" |
| 24 | |
| 25 | namespace mediastreamer { |
| 26 | |
| 27 | class H265NalUnpacker : public NalUnpacker { |
| 28 | public: |
| 29 | H265NalUnpacker() : NalUnpacker(new FuAggregator(), new ApSpliter()) { |
| 30 | } |
| 31 | |
| 32 | private: |
| 33 | class FuAggregator : public NalUnpacker::FuAggregatorInterface { |
| 34 | public: |
| 35 | mblk_t *feed(mblk_t *packet) override; |
| 36 | bool isAggregating() const override { |
| 37 | return _m != nullptr; |
| 38 | } |
| 39 | void reset() override; |
| 40 | mblk_t *completeAggregation() override; |
| 41 | }; |
| 42 | |
| 43 | class ApSpliter : public NalUnpacker::ApSpliterInterface { |
| 44 | public: |
| 45 | void feed(mblk_t *packet) override; |
| 46 | MSQueue *getNalus() override { |
| 47 | return &_q; |
| 48 | } |
| 49 | }; |
| 50 | |
| 51 | PacketType getNaluType(const mblk_t *nalu) const override; |
| 52 | }; |
| 53 | |
| 54 | } // namespace mediastreamer |