FlightGear next
continuous.hxx
Go to the documentation of this file.
1#pragma once
2
3#include <fstream>
4#include <mutex>
5#include <thread>
6
7#include <simgear/props/props.hxx>
8
9#include "replay-internal.hxx"
10
11
12struct Continuous : SGPropertyChangeListener {
13 explicit Continuous(std::shared_ptr<FGFlightRecorder> flight_recorder);
14
15 /* Callback for SGPropertyChangeListener. */
16 void valueChanged(SGPropertyNode* node) override;
17
18 std::shared_ptr<FGFlightRecorder> m_flight_recorder;
19
20 std::ifstream m_in;
21 bool m_in_multiplayer = false;
24 std::map<double, FGFrameInfo> m_in_time_to_frameinfo;
25 SGPropertyNode_ptr m_in_config;
26 double m_in_time_last = 0;
28 std::map<size_t, std::shared_ptr<FGReplayData>>
30
31 std::ifstream m_indexing_in;
32 std::streampos m_indexing_pos;
33
35 double m_replay_fixed_dt = -1;
37
38 // Only used for gathering statistics that are then written into
39 // properties.
40 //
43
44 // For writing Continuous fgtape file.
45 SGPropertyNode_ptr m_out_config;
46 std::ofstream m_out;
49};
50
51/* Attempts to load Continuous recording header properties into
52<properties>. If in is null we use internal std::fstream, otherwise we use *in.
53
54Returns 0 on success, +1 if we may succeed after further download, or -1 if
55recording is not a Continuous recording. */
56int loadContinuousHeader(const std::string& path, std::istream* in, SGPropertyNode* properties);
57
58
59/* Writes one frame of continuous record information. */
61 Continuous& continuous,
62 FGReplayData* r,
63 std::ostream& out,
64 SGPropertyNode_ptr config,
65 FGTapeType tape_type);
66
67/* Opens continuous recording file and writes header.
68
69If MetaData is unset, we initialise it by calling saveSetup(). Otherwise should
70be already set up.
71
72If Config is unset, we make it point to a new node populated by
73m_pRecorder->getConfig(). Otherwise it should be already set up to point to
74such information.
75
76If path_override is not "", we use it as the path (instead of the path
77determined by saveSetup(). */
78SGPropertyNode_ptr continuousWriteHeader(
79 Continuous& continuous,
80 FGFlightRecorder* m_pRecorder,
81 std::ofstream& out,
82 const SGPath& path,
83 FGTapeType tape_type);
84
85/* Replays one frame from Continuous recording.
86
87Returns true on success, otherwise we failed to read from Continuous recording.
88*/
89bool replayContinuous(FGReplayInternal& self, double time);
90
91/* Stops any video recording that was started because of
92continuous->m_replay_create_video. */
int loadContinuousHeader(const std::string &path, std::istream *in, SGPropertyNode *properties)
SGPropertyNode_ptr continuousWriteHeader(Continuous &continuous, FGFlightRecorder *m_pRecorder, std::ofstream &out, const SGPath &path, FGTapeType tape_type)
bool continuousWriteFrame(Continuous &continuous, FGReplayData *r, std::ostream &out, SGPropertyNode_ptr config, FGTapeType tape_type)
bool replayContinuous(FGReplayInternal &self, double time)
void continuous_replay_video_end(Continuous &continuous)
double m_replay_fixed_dt_prev
std::map< double, FGFrameInfo > m_in_time_to_frameinfo
std::ifstream m_indexing_in
Continuous(std::shared_ptr< FGFlightRecorder > flight_recorder)
double m_in_time_last
std::ifstream m_in
SGPropertyNode_ptr m_out_config
std::map< size_t, std::shared_ptr< FGReplayData > > m_in_pos_to_frame
std::shared_ptr< FGFlightRecorder > m_flight_recorder
SGPropertyNode_ptr m_in_config
double m_replay_fixed_dt
int m_out_compression
bool m_in_extra_properties
int m_num_frames_multiplayer
std::streampos m_indexing_pos
double m_in_frame_time_last
std::mutex m_in_time_to_frameinfo_lock
bool m_in_multiplayer
int m_num_frames_extra_properties
bool m_replay_create_video
void valueChanged(SGPropertyNode *node) override
int m_in_compression
std::ofstream m_out