FFmpegKit Linux API 5.1
Chapter.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 "Chapter.h"
21
22ffmpegkit::Chapter::Chapter(std::shared_ptr<rapidjson::Value> chapterValue) : _chapterValue{chapterValue} {
23}
24
25std::shared_ptr<int64_t> ffmpegkit::Chapter::getId() {
26 return getNumberProperty(KeyId);
27}
28
29std::shared_ptr<std::string> ffmpegkit::Chapter::getTimeBase() {
30 return getStringProperty(KeyTimeBase);
31}
32
33std::shared_ptr<int64_t> ffmpegkit::Chapter::getStart() {
34 return getNumberProperty(KeyStart);
35}
36
37std::shared_ptr<std::string> ffmpegkit::Chapter::getStartTime() {
38 return getStringProperty(KeyStartTime);
39}
40
41std::shared_ptr<int64_t> ffmpegkit::Chapter::getEnd() {
42 return getNumberProperty(KeyEnd);
43}
44
45std::shared_ptr<std::string> ffmpegkit::Chapter::getEndTime() {
46 return getStringProperty(KeyEndTime);
47}
48
49std::shared_ptr<rapidjson::Value> ffmpegkit::Chapter::getTags() {
50 return getProperty(KeyTags);
51}
52
53std::shared_ptr<std::string> ffmpegkit::Chapter::getStringProperty(const char* key) {
54 if (_chapterValue->HasMember(key)) {
55 return std::make_shared<std::string>((*_chapterValue)[key].GetString());
56 } else {
57 return nullptr;
58 }
59}
60
61std::shared_ptr<int64_t> ffmpegkit::Chapter::getNumberProperty(const char* key) {
62 if (_chapterValue->HasMember(key)) {
63 return std::make_shared<int64_t>((*_chapterValue)[key].GetInt64());
64 } else {
65 return nullptr;
66 }
67}
68
69std::shared_ptr<rapidjson::Value> ffmpegkit::Chapter::getProperty(const char* key) {
70 if (_chapterValue->HasMember(key)) {
71 auto value = std::make_shared<rapidjson::Value>();
72 *value = (*_chapterValue)[key];
73 return value;
74 } else {
75 return nullptr;
76 }
77}
78
79std::shared_ptr<rapidjson::Value> ffmpegkit::Chapter::getAllProperties() {
80 if (_chapterValue != nullptr) {
81 auto all = std::make_shared<rapidjson::Value>();
82 *all = (*_chapterValue);
83 return all;
84 } else {
85 return nullptr;
86 }
87}
std::shared_ptr< rapidjson::Value > getProperty(const char *key)
Definition: Chapter.cpp:69
std::shared_ptr< std::string > getStartTime()
Definition: Chapter.cpp:37
std::shared_ptr< int64_t > getNumberProperty(const char *key)
Definition: Chapter.cpp:61
std::shared_ptr< rapidjson::Value > getAllProperties()
Definition: Chapter.cpp:79
Chapter(std::shared_ptr< rapidjson::Value > chapterValue)
Definition: Chapter.cpp:22
std::shared_ptr< int64_t > getStart()
Definition: Chapter.cpp:33
std::shared_ptr< int64_t > getEnd()
Definition: Chapter.cpp:41
std::shared_ptr< std::string > getEndTime()
Definition: Chapter.cpp:45
std::shared_ptr< int64_t > getId()
Definition: Chapter.cpp:25
std::shared_ptr< std::string > getStringProperty(const char *key)
Definition: Chapter.cpp:53
std::shared_ptr< std::string > getTimeBase()
Definition: Chapter.cpp:29
std::shared_ptr< rapidjson::Value > getTags()
Definition: Chapter.cpp:49