Get an openshot::Frame object for a specific frame number of this reader.
| 144 | |
| 145 | // Get an openshot::Frame object for a specific frame number of this reader. |
| 146 | std::shared_ptr<Frame> QtHtmlReader::GetFrame(int64_t requested_frame) |
| 147 | { |
| 148 | // Create a scoped lock, allowing only a single thread to run the following code at one time |
| 149 | const std::lock_guard<std::recursive_mutex> lock(getFrameMutex); |
| 150 | |
| 151 | auto sample_count = Frame::GetSamplesPerFrame(requested_frame, info.fps, info.sample_rate, info.channels); |
| 152 | |
| 153 | if (image) |
| 154 | { |
| 155 | // Create or get frame object |
| 156 | auto image_frame = std::make_shared<Frame>( |
| 157 | requested_frame, image->size().width(), image->size().height(), |
| 158 | background_color, sample_count, info.channels); |
| 159 | |
| 160 | // Add Image data to frame |
| 161 | image_frame->AddImage(image); |
| 162 | |
| 163 | // return frame object |
| 164 | return image_frame; |
| 165 | } else { |
| 166 | // return empty frame |
| 167 | auto image_frame = std::make_shared<Frame>( |
| 168 | 1, 640, 480, background_color, sample_count, info.channels); |
| 169 | |
| 170 | // return frame object |
| 171 | return image_frame; |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | // Generate JSON string of this object |
| 176 | std::string QtHtmlReader::Json() const { |