21
21
22
22
#include < cstdint>
23
23
#include < iostream>
24
- // #include <memory>
25
24
#include < string>
26
25
#include < functional>
27
26
#include < iomanip>
28
27
#include < sstream>
29
28
#include < fstream>
29
+ #include < vector>
30
+ #include < memory>
30
31
#include < thread>
31
32
#include < mutex>
32
33
#include < Python.h>
@@ -56,30 +57,15 @@ namespace cmpc {
56
57
57
58
#ifdef __cplusplus
58
59
namespace cmpc {
59
- static const string av_make_error_string2 (int errnum) {
60
- char errbuf[AV_ERROR_MAX_STRING_SIZE];
61
- av_strerror (errnum, errbuf, AV_ERROR_MAX_STRING_SIZE);
62
- string strerrbuf = errbuf;
63
- return strerrbuf;
64
- }
60
+ const string av_make_error_string2_cpp (int errnum);
65
61
#undef av_err2str
66
- #define av_err2str (errnum ) av_make_error_string2(errnum).c_str()
67
- static const string av_ts_make_string_cpp (int64_t ts) {
68
- char tsstrbuf[AV_TS_MAX_STRING_SIZE];
69
- av_ts_make_string (tsstrbuf, ts);
70
- string strtsstrbuf = tsstrbuf;
71
- return strtsstrbuf;
72
- }
62
+ #define av_err2str (errnum ) av_make_error_string2_cpp(errnum)
63
+ const string av_ts_make_string_cpp (int64_t ts);
73
64
#undef av_ts2str
74
- #define av_ts2str (ts ) av_ts_make_string_cpp(ts).c_str()
75
- static const string av_ts_make_time_string_cpp (int64_t ts, AVRational* tb) {
76
- char tsstrbuf[AV_TS_MAX_STRING_SIZE];
77
- av_ts_make_time_string (tsstrbuf, ts, tb);
78
- string strtsstrbuf = tsstrbuf;
79
- return strtsstrbuf;
80
- }
65
+ #define av_ts2str (ts ) av_ts_make_string_cpp(ts)
66
+ const string av_ts_make_time_string_cpp (int64_t ts, AVRational* tb);
81
67
#undef av_ts2timestr
82
- #define av_ts2timestr (ts, tb ) av_ts_make_time_string_cpp(ts, tb).c_str()
68
+ #define av_ts2timestr (ts, tb ) av_ts_make_time_string_cpp(ts, tb)
83
69
}
84
70
#endif // __cplusplus
85
71
@@ -97,6 +83,27 @@ namespace cmpc {
97
83
98
84
struct SwsContext * sws_ctx;
99
85
} OutputStream;
86
+
87
+ // A wrapper of the char *[]
88
+ class CharList {
89
+ public:
90
+ CharList (void ); // Constructor.
91
+ CharList (const std::vector<string>& args); // Copy constructor (string ver).
92
+ CharList (const std::vector<string>&& args) noexcept ; // Move constructor (string ver).
93
+ ~CharList (void ); // 3-5 law. Destructor.
94
+ CharList (const CharList& ref); // Copy constructor.
95
+ CharList& operator =(const CharList& ref); // Copy assignment operator.
96
+ CharList (CharList&& ref) noexcept ; // Move constructor.
97
+ CharList& operator =(CharList&& ref) noexcept ; // Move assignment operator.
98
+ CharList& operator =(const std::vector<string>& args); // Copy assignment operator (string ver).
99
+ CharList& operator =(std::vector<string>&& args) noexcept ; // Move assignment operator (string ver).
100
+ void set (const std::vector<string>& args); // Set strings as data.
101
+ void set (std::vector<string>&& args) noexcept ; // Set strings as data (move).
102
+ void clear (); // clear all data.
103
+ std::shared_ptr<const char *> c_str (); // Equivalent conversion for char **
104
+ private:
105
+ std::vector<string> data;
106
+ };
100
107
}
101
108
102
109
// compatibility with newer API
0 commit comments