FlightGear next
replay.hxx
Go to the documentation of this file.
1// replay.hxx - a system to record and replay FlightGear flights
2//
3// Written by Curtis Olson, started July 2003.
4//
5// Copyright (C) 2003 Curtis L. Olson - http://www.flightgear.org/~curt
6//
7// This program is free software; you can redistribute it and/or
8// modify it under the terms of the GNU General Public License as
9// published by the Free Software Foundation; either version 2 of the
10// License, or (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful, but
13// WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15// General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program; if not, write to the Free Software
19// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20//
21// $Id$
22
23#pragma once
24
25#include <simgear/structure/subsystem_mgr.hxx>
26#include <simgear/io/iostreams/gzcontainerfile.hxx>
27#include <simgear/io/HTTPFileRequest.hxx>
28
30
31
32/* A recording/replay module for FlightGear flights. */
33struct FGReplay : SGSubsystem
34{
35 FGReplay ();
36 virtual ~FGReplay();
37
38 /* Subsystem API. */
39 void bind() override;
40 void init() override;
41 void reinit() override;
42 void unbind() override;
43 void update(double dt) override;
44
45 /* Subsystem identification. */
46 static const char* staticSubsystemClassId() { return "replay"; }
47
48 /* For built-in 'replay' command - replay using in-memory Normal recording.
49
50 new_tape: If true, we start at beginning of tape, otherwise we start at
51 loop interval.
52 */
53 bool start(bool new_tape=false);
54
55 /* For save and load tape operations from Flightgear GUI. */
56 bool saveTape(const SGPropertyNode* ConfigData);
57 bool loadTape(const SGPropertyNode* ConfigData);
58
59 /* Attempts to load Continuous recording header properties into
60 <properties>. If in is null we use internal std::fstream, otherwise we use
61 *in.
62
63 Returns 0 on success, +1 if we may succeed after further download, or -1 if
64 recording is not a Continuous recording.
65
66 For command line --load-tape=...
67 */
68 static int loadContinuousHeader(const std::string& path, std::istream* in, SGPropertyNode* properties);
69
70 /* Start replaying a flight recorder tape from disk.
71 filename
72 Path of recording.
73 preview
74 If true we read the header (and return it in <meta_meta> but do not
75 start replaying.
76 create_video
77 If true we automatically encode a video while replaying.
78 fixed_dt
79 If non-zero we set /sim/time/fixed-dt while replaying.
80 meta_meta
81 Filled in with contents of recording header's "meta" tree.
82 filerequest
83 If not null we use this to get called back as download of file
84 progresses, so that we can index the recording. Only useful for
85 Continuous recordings.
86 */
87 bool loadTape(
88 const SGPath& filename,
89 bool preview,
90 bool create_video,
91 double fixed_dt,
92 SGPropertyNode& meta_meta,
93 simgear::HTTP::FileRequestRef file_request=nullptr
94 );
95
96 /* Prepends /sim/replay/tape-directory and/or appends .fgtape etc.
97
98 For command line --load-tape=... */
99 static std::string makeTapePath(const std::string& tape_name);
100
101 /* Resets out static property nodes; to be called by fgStartNewReset(). */
102 static void resetStatisticsProperties();
103
104 std::unique_ptr<struct FGReplayInternal> m_internal;
105};
106
void init() override
Definition replay.cxx:40
void update(double dt) override
Definition replay.cxx:73
FGReplay()
Definition replay.cxx:29
bool loadTape(const SGPropertyNode *ConfigData)
Load a flight recorder tape from disk.
Definition replay.cxx:115
virtual ~FGReplay()
Definition replay.cxx:35
static const char * staticSubsystemClassId()
Definition replay.hxx:46
bool saveTape(const SGPropertyNode *ConfigData)
Write flight recorder tape to disk.
Definition replay.cxx:83
void unbind() override
Definition replay.cxx:58
static std::string makeTapePath(const std::string &tape_name)
Definition replay.cxx:103
static int loadContinuousHeader(const std::string &path, std::istream *in, SGPropertyNode *properties)
Definition replay.cxx:108
void reinit() override
Definition replay.cxx:46
bool start(bool new_tape=false)
Start replay session.
Definition replay.cxx:67
static void resetStatisticsProperties()
Definition replay.cxx:119
void bind() override
Definition replay.cxx:52
std::unique_ptr< struct FGReplayInternal > m_internal
Definition replay.hxx:104