CVB++ 15.0
detail_recording_engine.hpp
1#pragma once
2
3#include "../global.hpp"
4#include "../string.hpp"
5#include "../exception.hpp"
6
7#include "recording_settings.hpp"
8
9namespace Cvb
10{
11
12 CVB_BEGIN_INLINE_NS
13
14 namespace Movie2
15 {
16
17 namespace Private
18 {
19
20 class RecordingEngine;
21 using RecordingEnginePtr = std::shared_ptr<RecordingEngine>;
22
23 class DirectShowEngine;
24 using DirectShowEnginePtr = std::shared_ptr<DirectShowEngine>;
25
26 class RawVideoEngine;
27 using RawVideoEnginePtr = std::shared_ptr<RawVideoEngine>;
28
29 class RecordingEngine
30 {
31
32 public:
33 static RecordingEnginePtr Create(const RecordingSettings &settings);
34
35 virtual const RecordingSettings &Settings()
36 {
37 return settings_;
38 }
39
40 protected:
41 RecordingEngine(const RecordingSettings &settings) noexcept
42 : settings_(settings)
43 {
44 }
45
46 ~RecordingEngine() = default;
47
48 private:
49 RecordingEngine() noexcept = default;
50
51 protected:
52 const RecordingSettings &settings_;
53 };
54
55 class DirectShowEngine : public RecordingEngine
56 {
57 public:
58 DirectShowEngine(const DirectShowSettings &settings) noexcept
59 : RecordingEngine(settings)
60 {
61 }
62
63 virtual const DirectShowSettings &Settings() noexcept
64 {
65 return dynamic_cast<const DirectShowSettings &>(settings_);
66 }
67 };
68
69 class RawVideoEngine : public RecordingEngine
70 {
71 public:
72 RawVideoEngine(const RawVideoSettings &settings) noexcept
73 : RecordingEngine(settings)
74 {
75 }
76
77 virtual const RawVideoSettings &Settings() noexcept
78 {
79 return dynamic_cast<const RawVideoSettings &>(settings_);
80 }
81 };
82
83 inline RecordingEnginePtr RecordingEngine::Create(const RecordingSettings &settings)
84 {
86 {
87 const auto &s = dynamic_cast<const DirectShowSettings &>(settings);
89 }
90 else if (settings.EngineType() == RecordingEngineType::RawVideo)
91 {
92 const auto &s = dynamic_cast<const RawVideoSettings &>(settings);
94 }
95 else
96 throw std::runtime_error("failed to create recording engine (unsupported settings)");
97 }
98
99 } // namespace Private
100
101 } // namespace Movie2
102
103 CVB_END_INLINE_NS
104
105} // namespace Cvb
Settings for initializing a direct show engine recorder.
Definition recording_settings.hpp:87
Settings for initializing a raw video engine recorder.
Definition recording_settings.hpp:211
Settings for initializing a recorder.
Definition recording_settings.hpp:21
RecordingEngineType EngineType() const noexcept
Returns the engine type.
Definition recording_settings.hpp:64
T make_shared(T... args)
Record movies with classes from this tool.
Definition detail_recording_engine.hpp:15
@ DirectShow
Use DirectShow framework for recording AVI files.
Definition movie2.hpp:36
@ RawVideo
Use RawVideo for recording raw video.
Definition movie2.hpp:38
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
T dynamic_pointer_cast(T... args)