26
26
#include < iomanip>
27
27
#include < sstream>
28
28
#include < fstream>
29
+ #include < vector>
30
+ #include < memory>
29
31
#include < thread>
30
32
#include < mutex>
31
33
#include < Python.h>
@@ -55,30 +57,15 @@ namespace cmpc {
55
57
56
58
#ifdef __cplusplus
57
59
namespace cmpc {
58
- static const string av_make_error_string2 (int errnum) {
59
- char errbuf[AV_ERROR_MAX_STRING_SIZE];
60
- av_strerror (errnum, errbuf, AV_ERROR_MAX_STRING_SIZE);
61
- string strerrbuf = errbuf;
62
- return strerrbuf;
63
- }
60
+ const string av_make_error_string2_cpp (int errnum);
64
61
#undef av_err2str
65
- #define av_err2str (errnum ) av_make_error_string2(errnum).c_str()
66
- static const string av_ts_make_string_cpp (int64_t ts) {
67
- char tsstrbuf[AV_TS_MAX_STRING_SIZE];
68
- av_ts_make_string (tsstrbuf, ts);
69
- string strtsstrbuf = tsstrbuf;
70
- return strtsstrbuf;
71
- }
62
+ #define av_err2str (errnum ) av_make_error_string2_cpp(errnum)
63
+ const string av_ts_make_string_cpp (int64_t ts);
72
64
#undef av_ts2str
73
- #define av_ts2str (ts ) av_ts_make_string_cpp(ts).c_str()
74
- static const string av_ts_make_time_string_cpp (int64_t ts, AVRational* tb) {
75
- char tsstrbuf[AV_TS_MAX_STRING_SIZE];
76
- av_ts_make_time_string (tsstrbuf, ts, tb);
77
- string strtsstrbuf = tsstrbuf;
78
- return strtsstrbuf;
79
- }
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);
80
67
#undef av_ts2timestr
81
- #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)
82
69
}
83
70
#endif // __cplusplus
84
71
@@ -96,6 +83,27 @@ namespace cmpc {
96
83
97
84
struct SwsContext * sws_ctx;
98
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
+ };
99
107
}
100
108
101
109
// compatibility with newer API
@@ -104,4 +112,4 @@ namespace cmpc {
104
112
#define av_frame_free avcodec_free_frame
105
113
#endif
106
114
107
- #endif
115
+ #endif
0 commit comments