| FFmpegKit Linux API 6.0

Loading...
Searching...
No Matches
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
22 ffmpegkit::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
69std::shared_ptr<std::string> ffmpegkit::StreamInformation::getSampleAspectRatio() {
70 return getStringProperty(KeySampleAspectRatio);
71}
72
73std::shared_ptr<std::string> ffmpegkit::StreamInformation::getDisplayAspectRatio() {
74 return getStringProperty(KeyDisplayAspectRatio);
75}
76
77std::shared_ptr<std::string> ffmpegkit::StreamInformation::getAverageFrameRate() {
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}
StreamInformation.h
ffmpegkit::StreamInformation::getType
std::shared_ptr< std::string > getType()
Definition StreamInformation.cpp:29
ffmpegkit::StreamInformation::getProperty
std::shared_ptr< rapidjson::Value > getProperty(const char *key)
Definition StreamInformation.cpp:113
ffmpegkit::StreamInformation::getIndex
std::shared_ptr< int64_t > getIndex()
Definition StreamInformation.cpp:25
ffmpegkit::StreamInformation::getNumberProperty
std::shared_ptr< int64_t > getNumberProperty(const char *key)
Definition StreamInformation.cpp:105
ffmpegkit::StreamInformation::getSampleFormat
std::shared_ptr< std::string > getSampleFormat()
Definition StreamInformation.cpp:61
ffmpegkit::StreamInformation::getHeight
std::shared_ptr< int64_t > getHeight()
Definition StreamInformation.cpp:49
ffmpegkit::StreamInformation::getSampleAspectRatio
std::shared_ptr< std::string > getSampleAspectRatio()
Definition StreamInformation.cpp:69
ffmpegkit::StreamInformation::getTags
std::shared_ptr< rapidjson::Value > getTags()
Definition StreamInformation.cpp:93
ffmpegkit::StreamInformation::getSampleRate
std::shared_ptr< std::string > getSampleRate()
Definition StreamInformation.cpp:57
ffmpegkit::StreamInformation::getStringProperty
std::shared_ptr< std::string > getStringProperty(const char *key)
Definition StreamInformation.cpp:97
ffmpegkit::StreamInformation::getCodecLong
std::shared_ptr< std::string > getCodecLong()
Definition StreamInformation.cpp:37
ffmpegkit::StreamInformation::getDisplayAspectRatio
std::shared_ptr< std::string > getDisplayAspectRatio()
Definition StreamInformation.cpp:73
ffmpegkit::StreamInformation::getRealFrameRate
std::shared_ptr< std::string > getRealFrameRate()
Definition StreamInformation.cpp:81
ffmpegkit::StreamInformation::getWidth
std::shared_ptr< int64_t > getWidth()
Definition StreamInformation.cpp:45
ffmpegkit::StreamInformation::getFormat
std::shared_ptr< std::string > getFormat()
Definition StreamInformation.cpp:41
ffmpegkit::StreamInformation::getTimeBase
std::shared_ptr< std::string > getTimeBase()
Definition StreamInformation.cpp:85
ffmpegkit::StreamInformation::getAllProperties
std::shared_ptr< rapidjson::Value > getAllProperties()
Definition StreamInformation.cpp:123
ffmpegkit::StreamInformation::getAverageFrameRate
std::shared_ptr< std::string > getAverageFrameRate()
Definition StreamInformation.cpp:77
ffmpegkit::StreamInformation::StreamInformation
StreamInformation(std::shared_ptr< rapidjson::Value > streamInformationValue)
Definition StreamInformation.cpp:22
ffmpegkit::StreamInformation::getCodecTimeBase
std::shared_ptr< std::string > getCodecTimeBase()
Definition StreamInformation.cpp:89
ffmpegkit::StreamInformation::getBitrate
std::shared_ptr< std::string > getBitrate()
Definition StreamInformation.cpp:53
ffmpegkit::StreamInformation::getChannelLayout
std::shared_ptr< std::string > getChannelLayout()
Definition StreamInformation.cpp:65
ffmpegkit::StreamInformation::getCodec
std::shared_ptr< std::string > getCodec()
Definition StreamInformation.cpp:33