Project Malmo  0.37.0
MissionRecordSpec.h
1 // --------------------------------------------------------------------------------------------------
2 // Copyright (c) 2016 Microsoft Corporation
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
5 // associated documentation files (the "Software"), to deal in the Software without restriction,
6 // including without limitation the rights to use, copy, modify, merge, publish, distribute,
7 // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in all copies or
11 // substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
14 // NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 // --------------------------------------------------------------------------------------------------
19 
20 #ifndef _MISSIONRECORDSPEC_H_
21 #define _MISSIONRECORDSPEC_H_
22 
23 // Boost:
24 #include <boost/filesystem.hpp>
25 
26 // STL:
27 #include <cstdint>
28 #include <fstream>
29 #include <string>
30 #include <vector>
31 
32 // Local:
33 #include "Logger.h"
34 #include "TimestampedVideoFrame.h"
35 
36 #define LOG_COMPONENT Logger::LOG_RECORDING
37 
38 namespace malmo
39 {
42  {
43  MALMO_LOGGABLE_OBJECT(MissionRecordSpec)
44  friend class MissionRecord;
45 
46  public:
47 
50 
55  MissionRecordSpec(std::string destination);
56 
58  void setDestination(const std::string& destination);
59 
66  void recordMP4(int frames_per_second, int64_t bit_rate);
67 
75  void recordMP4(TimestampedVideoFrame::FrameType type, int frames_per_second, int64_t bit_rate, bool drop_input_frames);
76 
81 
84 
86  void recordRewards();
87 
90 
92  bool isRecording() const;
93 
94  friend std::ostream& operator<<(std::ostream& os, const MissionRecordSpec& msp);
95 
96  private:
97  enum FrameRecordingType
98  {
99  BMP,
100  VIDEO
101  };
102  struct FrameRecordingSpec
103  {
104  FrameRecordingType fr_type;
105  int64_t mp4_bit_rate;
106  int mp4_fps;
107  bool drop_input_frames;
108  };
109  std::map<TimestampedVideoFrame::FrameType, FrameRecordingSpec> video_recordings;
110  bool is_recording_observations;
111  bool is_recording_rewards;
112  bool is_recording_commands;
113  std::string destination;
114  };
115 }
116 
117 #undef LOG_COMPONENT
118 #endif
Specifies the type of data that should be recorded from the mission.
Definition: MissionRecordSpec.h:42
MissionRecordSpec()
Constructs an empty mission record specification, saying that nothing should be recorded.
void recordMP4(TimestampedVideoFrame::FrameType type, int frames_per_second, int64_t bit_rate, bool drop_input_frames)
Requests that video be recorded, for the specified video producer, at the specified quality.
void setDestination(const std::string &destination)
Specifies the destination for the recording.
void recordObservations()
Requests that observations be recorded.
bool isRecording() const
Are we recording anything?
void recordRewards()
Requests that rewards be recorded.
MissionRecordSpec(std::string destination)
Constructs a mission record with a target file (e.g.
void recordMP4(int frames_per_second, int64_t bit_rate)
Requests that video be recorded, for each video producer, at the specified quality.
void recordBitmaps(TimestampedVideoFrame::FrameType type)
Requests that video be recorded, for the specified video producer, in individual bitmap frames.
void recordCommands()
Requests that commands be recorded.
FrameType
Definition: TimestampedVideoFrame.h:42