MCPcopy Create free account
hub / github.com/OpenShot/libopenshot / JsonValue

Method JsonValue

src/ReaderBase.cpp:109–157  ·  view source on GitHub ↗

Generate Json::Value for this object

Source from the content-addressed store, hash-verified

107
108// Generate Json::Value for this object
109Json::Value ReaderBase::JsonValue() const {
110
111 // Create root json object
112 Json::Value root;
113 root["has_video"] = info.has_video;
114 root["has_audio"] = info.has_audio;
115 root["has_single_image"] = info.has_single_image;
116 root["duration"] = info.duration;
117 root["file_size"] = static_cast<Json::Value::Int64>(info.file_size); // direct 64-bit int
118 root["height"] = info.height;
119 root["width"] = info.width;
120 root["pixel_format"] = info.pixel_format;
121 root["fps"] = Json::Value(Json::objectValue);
122 root["fps"]["num"] = info.fps.num;
123 root["fps"]["den"] = info.fps.den;
124 root["video_bit_rate"] = info.video_bit_rate;
125 root["pixel_ratio"] = Json::Value(Json::objectValue);
126 root["pixel_ratio"]["num"] = info.pixel_ratio.num;
127 root["pixel_ratio"]["den"] = info.pixel_ratio.den;
128 root["display_ratio"] = Json::Value(Json::objectValue);
129 root["display_ratio"]["num"] = info.display_ratio.num;
130 root["display_ratio"]["den"] = info.display_ratio.den;
131 root["vcodec"] = info.vcodec;
132 root["video_length"] = static_cast<Json::Value::Int64>(info.video_length);
133 root["video_stream_index"] = info.video_stream_index;
134 root["video_timebase"] = Json::Value(Json::objectValue);
135 root["video_timebase"]["num"] = info.video_timebase.num;
136 root["video_timebase"]["den"] = info.video_timebase.den;
137 root["interlaced_frame"] = info.interlaced_frame;
138 root["top_field_first"] = info.top_field_first;
139 root["acodec"] = info.acodec;
140 root["audio_bit_rate"] = info.audio_bit_rate;
141 root["sample_rate"] = info.sample_rate;
142 root["channels"] = info.channels;
143 root["channel_layout"] = info.channel_layout;
144 root["audio_stream_index"] = info.audio_stream_index;
145 root["audio_timebase"] = Json::Value(Json::objectValue);
146 root["audio_timebase"]["num"] = info.audio_timebase.num;
147 root["audio_timebase"]["den"] = info.audio_timebase.den;
148
149 // Append metadata map
150 root["metadata"] = Json::Value(Json::objectValue);
151
152 for (const auto it : info.metadata)
153 root["metadata"][it.first] = it.second;
154
155 // return JsonValue
156 return root;
157}
158
159// Load Json::Value into this object
160void ReaderBase::SetJsonValue(const Json::Value root) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected