| 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 |
#include "videotoolbox-h264-utilities.h" |
| 22 |
|
| 23 |
using namespace std; |
| 24 |
|
| 25 |
namespace mediastreamer { |
| 26 |
|
| 27 |
CMVideoCodecType VideoToolboxH264Utilities::getCodecType() const { |
| 28 |
return kCMVideoCodecType_H264; |
| 29 |
} |
| 30 |
|
| 31 |
CFStringRef VideoToolboxH264Utilities::getDefaultProfileLevel() const { |
| 32 |
return kVTProfileLevel_H264_Baseline_AutoLevel; |
| 33 |
} |
| 34 |
|
| 35 |
void VideoToolboxH264Utilities::getParameterSet(const CMFormatDescriptionRef format, |
| 36 |
size_t offset, |
| 37 |
const uint8_t *¶meterSet, |
| 38 |
size_t ¶meterSetSize, |
| 39 |
size_t ¶meterSetsCount) const { |
| 40 |
OSStatus status = CMVideoFormatDescriptionGetH264ParameterSetAtIndex( |
| 41 |
format, offset, ¶meterSet, ¶meterSetSize, ¶meterSetsCount, nullptr); |
| 42 |
if (status != noErr) throw AppleOSError(status); |
| 43 |
} |
| 44 |
|
| 45 |
CMFormatDescriptionRef VideoToolboxH264Utilities::createFormatDescription(size_t parameterSetsCount, |
| 46 |
const uint8_t *parameterSets[], |
| 47 |
const size_t parameterSetSizes[]) const { |
| 48 |
CMFormatDescriptionRef formatDesc; |
| 49 |
OSStatus status = CMVideoFormatDescriptionCreateFromH264ParameterSets(nullptr, parameterSetsCount, parameterSets, |
| 50 |
parameterSetSizes, 4, &formatDesc); |
| 51 |
if (status != noErr) { |
| 52 |
throw AppleOSError(status); |
| 53 |
} |
| 54 |
return formatDesc; |
| 55 |
} |
| 56 |
|
| 57 |
} // namespace mediastreamer |