FFmpegKit Linux API 5.1
StreamInformation.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 Taner Sener
3 *
4 * This file is part of FFmpegKit.
5 *
6 * FFmpegKit is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * FFmpegKit is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "StreamInformation.h"
21
22ffmpegkit::StreamInformation::StreamInformation(std::shared_ptr<rapidjson::Value> streamInformationValue) : _streamInformationValue{streamInformationValue} {
23}
24
25std::shared_ptr<int64_t> ffmpegkit::StreamInformation::getIndex() {
26 return getNumberProperty(KeyIndex);
27}
28
29std::shared_ptr<std::string> ffmpegkit::StreamInformation::getType() {
30 return getStringProperty(KeyType);
31}
32
33std::shared_ptr<std::string> ffmpegkit::StreamInformation::getCodec() {
34 return getStringProperty(KeyCodec);
35}
36
37std::shared_ptr<std::string> ffmpegkit::StreamInformation::getCodecLong() {
38 return getStringProperty(KeyCodecLong);
39}
40
41std::shared_ptr<std::string> ffmpegkit::StreamInformation::getFormat() {
42 return getStringProperty(KeyFormat);
43}
44
45std::shared_ptr<int64_t> ffmpegkit::StreamInformation::getWidth() {
46 return getNumberProperty(KeyWidth);
47}
48
49std::shared_ptr<int64_t> ffmpegkit::StreamInformation::getHeight() {
50 return getNumberProperty(KeyHeight);
51}
52
53std::shared_ptr<std::string> ffmpegkit::StreamInformation::getBitrate() {
54 return getStringProperty(KeyBitRate);
55}
56
57std::shared_ptr<std::string> ffmpegkit::StreamInformation::getSampleRate() {
58 return getStringProperty(KeySampleRate);
59}
60
61std::shared_ptr<std::string> ffmpegkit::StreamInformation::getSampleFormat() {
62 return getStringProperty(KeySampleFormat);
63}
64
65std::shared_ptr<std::string> ffmpegkit::StreamInformation::getChannelLayout() {
66 return getStringProperty(KeyChannelLayout);
67}
68
70 return getStringProperty(KeySampleAspectRatio);
71}
72
74 return getStringProperty(KeyDisplayAspectRatio);
75}
76
78 return getStringProperty(KeyAverageFrameRate);
79}
80
81std::shared_ptr<std::string> ffmpegkit::StreamInformation::getRealFrameRate() {
82 return getStringProperty(KeyRealFrameRate);
83}
84
85std::shared_ptr<std::string> ffmpegkit::StreamInformation::getTimeBase() {
86 return getStringProperty(KeyTimeBase);
87}
88
89std::shared_ptr<std::string> ffmpegkit::StreamInformation::getCodecTimeBase() {
90 return getStringProperty(KeyCodecTimeBase);
91}
92
93std::shared_ptr<rapidjson::Value> ffmpegkit::StreamInformation::getTags() {
94 return getProperty(KeyTags);
95}
96
97std::shared_ptr<std::string> ffmpegkit::StreamInformation::getStringProperty(const char* key) {
98 if (_streamInformationValue->HasMember(key)) {
99 return std::make_shared<std::string>((*_streamInformationValue)[key].GetString());
100 } else {
101 return nullptr;
102 }
103}
104
105std::shared_ptr<int64_t> ffmpegkit::StreamInformation::getNumberProperty(const char* key) {
106 if (_streamInformationValue->HasMember(key)) {
107 return std::make_shared<int64_t>((*_streamInformationValue)[key].GetInt64());
108 } else {
109 return nullptr;
110 }
111}
112
113std::shared_ptr<rapidjson::Value> ffmpegkit::StreamInformation::getProperty(const char* key) {
114 if (_streamInformationValue->HasMember(key)) {
115 auto value = std::make_shared<rapidjson::Value>();
116 *value = (*_streamInformationValue)[key];
117 return value;
118 } else {
119 return nullptr;
120 }
121}
122
123std::shared_ptr<rapidjson::Value> ffmpegkit::StreamInformation::getAllProperties() {
124 if (_streamInformationValue != nullptr) {
125 auto all = std::make_shared<rapidjson::Value>();
126 *all = (*_streamInformationValue);
127 return all;
128 } else {
129 return nullptr;
130 }
131}
std::shared_ptr< std::string > getType()
std::shared_ptr< rapidjson::Value > getProperty(const char *key)
std::shared_ptr< int64_t > getIndex()
std::shared_ptr< int64_t > getNumberProperty(const char *key)
std::shared_ptr< std::string > getSampleFormat()
std::shared_ptr< int64_t > getHeight()
std::shared_ptr< std::string > getSampleAspectRatio()
std::shared_ptr< rapidjson::Value > getTags()
std::shared_ptr< std::string > getSampleRate()
std::shared_ptr< std::string > getStringProperty(const char *key)
std::shared_ptr< std::string > getCodecLong()
std::shared_ptr< std::string > getDisplayAspectRatio()
std::shared_ptr< std::string > getRealFrameRate()
std::shared_ptr< int64_t > getWidth()
std::shared_ptr< std::string > getFormat()
std::shared_ptr< std::string > getTimeBase()
std::shared_ptr< rapidjson::Value > getAllProperties()
std::shared_ptr< std::string > getAverageFrameRate()
StreamInformation(std::shared_ptr< rapidjson::Value > streamInformationValue)
std::shared_ptr< std::string > getCodecTimeBase()
std::shared_ptr< std::string > getBitrate()
std::shared_ptr< std::string > getChannelLayout()
std::shared_ptr< std::string > getCodec()