forked from avTranscoder/avTranscoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibrary.cpp
More file actions
183 lines (161 loc) · 5.31 KB
/
Library.cpp
File metadata and controls
183 lines (161 loc) · 5.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#include "Library.hpp"
extern "C" {
#include <libavutil/version.h>
#include <libavcodec/version.h>
#include <libswscale/version.h>
#include <libswscale/swscale.h>
#include <libavfilter/version.h>
#ifdef AVTRANSCODER_LIBAV_DEPENDENCY
#include <libavresample/version.h>
#else
#include <libswresample/version.h>
#endif
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavfilter/avfilter.h>
}
#include <cstring>
#include <sstream>
#include <algorithm>
namespace avtranscoder
{
Library::Library(const std::string& name, const std::string& license, const size_t major, const size_t minor,
const size_t release)
: _name(name)
, _licence(license)
, _major(major)
, _minor(minor)
, _release(release)
{
}
std::string Library::getName()
{
return _name;
}
std::vector<size_t> Library::getVersion()
{
std::vector<size_t> version;
version.push_back(_major);
version.push_back(_minor);
version.push_back(_release);
return version;
}
std::string Library::getStringVersion()
{
std::stringstream version;
version << _major << ".";
version << _minor << ".";
version << _release;
return version.str();
}
size_t Library::getMajorVersion()
{
return _major;
}
size_t Library::getMinorVersion()
{
return _minor;
}
size_t Library::getReleaseVersion()
{
return _release;
}
std::string Library::getLicense()
{
return _licence;
}
Libraries getLibraries()
{
Libraries libs;
libs.push_back(Library("avtranscoder", "GPL v2 or LGPL v2.1", AVTRANSCODER_VERSION_MAJOR, AVTRANSCODER_VERSION_MINOR,
AVTRANSCODER_VERSION_MICRO));
libs.push_back(
Library("avutil", avutil_license(), LIBAVUTIL_VERSION_MAJOR, LIBAVUTIL_VERSION_MINOR, LIBAVUTIL_VERSION_MICRO));
libs.push_back(Library("avformat", avformat_license(), LIBAVFORMAT_VERSION_MAJOR, LIBAVFORMAT_VERSION_MINOR,
LIBAVFORMAT_VERSION_MICRO));
libs.push_back(
Library("avcodec", avcodec_license(), LIBAVCODEC_VERSION_MAJOR, LIBAVCODEC_VERSION_MINOR, LIBAVCODEC_VERSION_MICRO));
#ifdef AVTRANSCODER_LIBAV_DEPENDENCY
libs.push_back(Library("avresample", avutil_license(), LIBAVRESAMPLE_VERSION_MAJOR, LIBAVRESAMPLE_VERSION_MINOR,
LIBAVRESAMPLE_VERSION_MICRO));
#else
libs.push_back(Library("swresample", avutil_license(), LIBSWRESAMPLE_VERSION_MAJOR, LIBSWRESAMPLE_VERSION_MINOR,
LIBSWRESAMPLE_VERSION_MICRO));
#endif
libs.push_back(
Library("swscale", swscale_license(), LIBSWSCALE_VERSION_MAJOR, LIBSWSCALE_VERSION_MINOR, LIBSWSCALE_VERSION_MICRO));
libs.push_back(Library("avfilter", avfilter_license(), LIBAVFILTER_VERSION_MAJOR, LIBAVFILTER_VERSION_MINOR,
LIBAVFILTER_VERSION_MICRO));
return libs;
}
std::vector<std::string> getInputExtensions()
{
std::vector<std::string> extensions;
const AVInputFormat* iFormat = NULL;
void *iFormatOpaque = NULL;
while((iFormat = av_demuxer_iterate(&iFormatOpaque)))
{
if(iFormat->extensions != NULL)
{
// parse extensions
std::string exts = std::string(iFormat->extensions);
char* ext = strtok(const_cast<char*>(exts.c_str()), ",");
while(ext != NULL)
{
extensions.push_back(std::string(ext));
ext = strtok(NULL, ",");
}
// parse name (name's format defines (in general) extensions )
// don't need to do it in recent LibAV/FFMpeg versions
exts = std::string(iFormat->name);
ext = strtok(const_cast<char*>(exts.c_str()), ",");
while(ext != NULL)
{
extensions.push_back(std::string(ext));
ext = strtok(NULL, ",");
}
}
}
// sort
std::sort(extensions.begin(), extensions.end());
// suppress duplicates
std::vector<std::string>::iterator last = std::unique(extensions.begin(), extensions.end());
extensions.erase(last, extensions.end());
return extensions;
}
std::vector<std::string> getOutputExtensions()
{
std::vector<std::string> extensions;
const AVOutputFormat* oFormat = NULL;
void *oFormatOpaque = NULL;
while((oFormat = av_muxer_iterate(&oFormatOpaque)))
{
if(oFormat->extensions != NULL)
{
// parse extensions
std::string exts = std::string(oFormat->extensions);
char* ext = strtok(const_cast<char*>(exts.c_str()), ",");
while(ext != NULL)
{
extensions.push_back(std::string(ext));
ext = strtok(NULL, ",");
}
// parse name (name's format defines (in general) extensions )
// don't need to do it in recent LibAV/FFMpeg versions
exts = std::string(oFormat->name);
ext = strtok(const_cast<char*>(exts.c_str()), ",");
while(ext != NULL)
{
extensions.push_back(std::string(ext));
ext = strtok(NULL, ",");
}
}
}
// sort
std::sort(extensions.begin(), extensions.end());
// suppress duplicates
std::vector<std::string>::iterator last = std::unique(extensions.begin(), extensions.end());
extensions.erase(last, extensions.end());
return extensions;
}
}