Skip to content

Commit 81d02ae

Browse files
author
Clement Champetier
committed
Merge branch 'develop' of https://github.com/mikrosimage/avTranscoder into dev_useFFmpegLogSystem
Conflicts: src/AvTranscoder/profile/ProfileLoader.cpp
2 parents 2e00e9b + 5e5d310 commit 81d02ae

21 files changed

+301
-126
lines changed

CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,9 @@ endif()
3030

3131

3232
add_subdirectory(src)
33-
add_subdirectory(app)
33+
34+
if(DISABLE_APPS)
35+
message("Apps disabled, will not build applications.")
36+
else()
37+
add_subdirectory(app)
38+
endif()

INSTALL.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Compilation
2+
3+
AvTranscoder uses CMake as build system.
4+
5+
#### To build
6+
```
7+
mkdir build && cd build
8+
cmake ..
9+
make
10+
make install
11+
```
12+
13+
#### To indicate a specific ffmpeg/libav folder
14+
```
15+
cmake .. -DFFMPEG_INCLUDE_DIR=/path/to/include/ -DFFMPEG_LIBRARY_DIR=/path/to/lib/
16+
```
17+
18+
#### To not build apps
19+
```
20+
cmake .. -DDISABLE_APPS=True
21+
```
22+
23+
#### To not build bindings
24+
```
25+
cmake .. -DDISABLE_BINDINGS=True
26+
```
27+
```
28+
cmake .. -DDISABLE_PYTHON_BINDING=True
29+
```
30+
```
31+
cmake .. -DDISABLE_JAVA_BINDING=True
32+
```
33+
34+
#### Other useful flags
35+
###### To install at a specific location
36+
```
37+
cmake .. -DCMAKE_INSTALL_PREFIX=/path/to/install
38+
```
39+
###### To build Release/Debug version
40+
```
41+
cmake .. -DCMAKE_BUILD_TYPE=Release/Debug
42+
```

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Based on Libav/FFmpeg libraries to support various video and audio formats, avTr
1313
#### License
1414
See [**COPYING.md**](COPYING.md)
1515

16+
#### Compilation
17+
See [**INSTALL.md**](INSTALL.md)
18+
1619
#### How to use
1720
Check out applications contained in the project to see examples of how to use the library in C++, Java or Python.
1821

src/AvTranscoder/avTranscoder.i

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,18 @@
1515
%include "AvTranscoder/swig/avLogLevel.i"
1616

1717
%{
18-
#include <AvTranscoder/ProfileLoader.hpp>
1918
#include <AvTranscoder/Option.hpp>
2019
%}
2120

2221
namespace std {
2322
%template(IntPair) pair< size_t, size_t >;
24-
%template(ProfileMap) map< string, string >;
25-
%template(ProfilesVector) vector< map< string, string > >;
2623
}
2724

2825
%include "AvTranscoder/progress/progress.i"
2926
%include "AvTranscoder/mediaProperty/mediaProperty.i"
3027
%include "AvTranscoder/frame/frame.i"
28+
%include "AvTranscoder/profile/profile.i"
3129

32-
%include <AvTranscoder/ProfileLoader.hpp>
3330
%include <AvTranscoder/Option.hpp>
3431

3532
%include "AvTranscoder/codec/codec.i"

src/AvTranscoder/common.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef _AV_TRANSCODER_COMMON_HPP_
22
#define _AV_TRANSCODER_COMMON_HPP_
33

4+
#include <AvTranscoder/system.hpp>
5+
46
extern "C" {
57
#ifndef __STDC_CONSTANT_MACROS
68
#define __STDC_CONSTANT_MACROS
@@ -18,7 +20,7 @@ extern "C" {
1820
#ifdef SWIG
1921
#define AvExport
2022
#else
21-
#if ( defined( WIN32 ) || defined( WIN64 ) || defined( _WIN32 ) || defined( _WIN64 ) || defined( __WINDOWS__ ) || defined( __TOS_WIN__ ) || defined( __WIN32__ ) )
23+
#if defined( __WINDOWS__ )
2224
#define AvExport __declspec( dllexport )
2325
#elif defined( __GNUC__ ) // Add compiler definition here...
2426
#if __GNUC__ - 0 > 3 || ( __GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 > 2 )

src/AvTranscoder/decoder/AudioDecoder.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define _AV_TRANSCODER_ESSENCE_STREAM_AV_INPUT_AUDIO_HPP_
33

44
#include "IDecoder.hpp"
5-
#include <AvTranscoder/ProfileLoader.hpp>
5+
#include <AvTranscoder/profile/ProfileLoader.hpp>
66

77
struct AVFrame;
88

src/AvTranscoder/decoder/VideoDecoder.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define _AV_TRANSCODER_DECODER_VIDEO_DECODER_HPP_
33

44
#include "IDecoder.hpp"
5-
#include <AvTranscoder/ProfileLoader.hpp>
5+
#include <AvTranscoder/profile/ProfileLoader.hpp>
66

77
struct AVFrame;
88

src/AvTranscoder/encoder/AudioEncoder.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "IEncoder.hpp"
55
#include <AvTranscoder/codec/AudioCodec.hpp>
6-
#include <AvTranscoder/ProfileLoader.hpp>
6+
#include <AvTranscoder/profile/ProfileLoader.hpp>
77

88
namespace avtranscoder
99
{

src/AvTranscoder/encoder/VideoEncoder.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "IEncoder.hpp"
55
#include <AvTranscoder/codec/VideoCodec.hpp>
6-
#include <AvTranscoder/ProfileLoader.hpp>
6+
#include <AvTranscoder/profile/ProfileLoader.hpp>
77

88
namespace avtranscoder
99
{

src/AvTranscoder/file/IOutputFile.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <AvTranscoder/codec/DataCodec.hpp>
99

1010
#include <AvTranscoder/stream/OutputStream.hpp>
11-
#include <AvTranscoder/ProfileLoader.hpp>
1211

1312
#include <string>
1413
#include <stdexcept>

src/AvTranscoder/file/InputFile.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <AvTranscoder/stream/InputStream.hpp>
88
#include <AvTranscoder/mediaProperty/FileProperties.hpp>
99
#include <AvTranscoder/progress/IProgress.hpp>
10-
#include <AvTranscoder/ProfileLoader.hpp>
10+
#include <AvTranscoder/profile/ProfileLoader.hpp>
1111

1212
#include <string>
1313
#include <vector>

src/AvTranscoder/frame/AudioFrame.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define _AV_TRANSCODER_FRAME_AUDIO_FRAME_HPP_
33

44
#include "Frame.hpp"
5-
#include <AvTranscoder/ProfileLoader.hpp>
5+
#include <AvTranscoder/profile/ProfileLoader.hpp>
66

77
extern "C" {
88
#include <libavutil/samplefmt.h>

src/AvTranscoder/frame/VideoFrame.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define _AV_TRANSCODER_FRAME_VIDEO_FRAME_HPP_
33

44
#include "Frame.hpp"
5-
#include <AvTranscoder/ProfileLoader.hpp>
5+
#include <AvTranscoder/profile/ProfileLoader.hpp>
66

77
extern "C" {
88
#include <libavutil/pixfmt.h>

src/AvTranscoder/ProfileLoader.cpp renamed to src/AvTranscoder/profile/ProfileLoader.cpp

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#include "ProfileLoader.hpp"
22

3-
#include "common.hpp"
3+
#include "util.hpp"
44

55
#include <fstream>
66
#include <cstdlib>
77
#include <stdexcept>
8-
#include <dirent.h>
98

109
namespace avtranscoder
1110
{
@@ -20,7 +19,7 @@ void ProfileLoader::loadProfile( const std::string& avProfileFileName )
2019
{
2120
std::ifstream infile;
2221
infile.open( avProfileFileName.c_str(), std::ifstream::in );
23-
22+
2423
ProfileLoader::Profile customProfile;
2524

2625
std::string line;
@@ -35,7 +34,7 @@ void ProfileLoader::loadProfile( const std::string& avProfileFileName )
3534
}
3635

3736
void ProfileLoader::loadProfiles( const std::string& avProfilesPath )
38-
{
37+
{
3938
std::string realAvProfilesPath = avProfilesPath;
4039
if( realAvProfilesPath.empty() )
4140
{
@@ -46,7 +45,7 @@ void ProfileLoader::loadProfiles( const std::string& avProfilesPath )
4645
else
4746
realAvProfilesPath = AVTRANSCODER_DEFAULT_AVPROFILES;
4847
}
49-
48+
5049
std::vector< std::string > paths;
5150
split( paths, realAvProfilesPath, ":" );
5251
for( std::vector< std::string >::iterator dirIt = paths.begin(); dirIt != paths.end(); ++dirIt )
@@ -202,35 +201,4 @@ bool ProfileLoader::checkAudioProfile( const Profile& profileToCheck )
202201
return isValid;
203202
}
204203

205-
void split( std::vector< std::string >& splitString, const std::string& inputString, const std::string& splitChars )
206-
{
207-
char* part = strtok( const_cast<char*>( inputString.c_str() ), splitChars.c_str() );
208-
while( part != NULL )
209-
{
210-
splitString.push_back( std::string( part ) );
211-
part = strtok( NULL, splitChars.c_str() );
212-
}
213-
}
214-
215-
int getFilesInDir( const std::string& dir, std::vector< std::string >& files )
216-
{
217-
DIR *dp;
218-
struct dirent *dirp;
219-
if( ( dp = opendir( dir.c_str() ) ) == NULL )
220-
{
221-
LOG_ERROR( "Can't get files in directory " << dir << " (" << errno << ")" )
222-
return errno;
223-
}
224-
225-
while( ( dirp = readdir( dp ) ) != NULL )
226-
{
227-
std::string filename( dirp->d_name );
228-
if( filename == "." || filename == ".." )
229-
continue;
230-
files.push_back( filename );
231-
}
232-
closedir( dp );
233-
return 0;
234-
}
235-
236204
}

src/AvTranscoder/ProfileLoader.hpp renamed to src/AvTranscoder/profile/ProfileLoader.hpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#ifndef _AV_TRANSCODER_PROFILE_HPP_
22
#define _AV_TRANSCODER_PROFILE_HPP_
33

4-
#include "common.hpp"
4+
#include <AvTranscoder/common.hpp>
55

66
#include <string>
7-
#include <cstring>
87
#include <vector>
98
#include <map>
109

@@ -74,10 +73,5 @@ class AvExport ProfileLoader
7473
Profiles _profiles;
7574
};
7675

77-
#ifndef SWIG
78-
void split( std::vector< std::string >& splitString, const std::string& inputString, const std::string& splitChars = ";" );
79-
int getFilesInDir( const std::string& dir, std::vector< std::string >& files );
80-
#endif
81-
8276
}
8377
#endif

src/AvTranscoder/profile/profile.i

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
%{
2+
#include <AvTranscoder/profile/ProfileLoader.hpp>
3+
%}
4+
5+
namespace std {
6+
%template(ProfileMap) map< string, string >;
7+
%template(ProfilesVector) vector< map< string, string > >;
8+
}
9+
10+
%include <AvTranscoder/profile/ProfileLoader.hpp>

src/AvTranscoder/profile/util.hpp

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#ifndef _AV_TRANSCODER_PROFILE_UTIL_HPP_
2+
#define _AV_TRANSCODER_PROFILE_UTIL_HPP_
3+
4+
#if defined ( __LINUX__ )
5+
6+
#define DIRLIST_SEP_CHARS ":;"
7+
#define DIRSEP "/"
8+
#include <dirent.h>
9+
10+
#elif defined ( __MACOS__ )
11+
12+
#define DIRLIST_SEP_CHARS ";:"
13+
#define DIRSEP "/"
14+
#include <dirent.h>
15+
16+
#elif defined ( __WINDOWS__ )
17+
18+
#define DIRLIST_SEP_CHARS ";"
19+
#define DIRSEP "\\"
20+
21+
// CINTERFACE needs to be declared if compiling with VC++
22+
#include <shlobj.h>
23+
#include <tchar.h>
24+
#ifndef _MSC_VER
25+
#define SHGFP_TYPE_CURRENT 0
26+
#endif
27+
28+
#endif
29+
30+
#include <string>
31+
#include <iostream>
32+
33+
namespace avtranscoder
34+
{
35+
36+
void split( std::vector< std::string >& splitString, const std::string& inputString, const std::string& splitChars )
37+
{
38+
char* part = strtok( const_cast<char*>( inputString.c_str() ), splitChars.c_str() );
39+
while( part != NULL )
40+
{
41+
splitString.push_back( std::string( part ) );
42+
part = strtok( NULL, splitChars.c_str() );
43+
}
44+
}
45+
46+
int getFilesInDir( const std::string& dir, std::vector< std::string >& files )
47+
{
48+
#if defined ( __WINDOWS__ )
49+
WIN32_FIND_DATA findData;
50+
HANDLE findHandle;
51+
52+
findHandle = FindFirstFile( ( dir + "\\*" ).c_str(), &findData );
53+
if( findHandle == INVALID_HANDLE_VALUE )
54+
{
55+
return -1;
56+
}
57+
while(1)
58+
{
59+
const std::string filename( findData.cFileName );
60+
bool isdir = ( findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) != 0;
61+
if( ! isdir )
62+
files.push_back( filename );
63+
64+
int rval = FindNextFile( findHandle, &findData );
65+
if( rval == 0 )
66+
break;
67+
}
68+
69+
#else
70+
DIR *dp;
71+
struct dirent *dirp;
72+
if( ( dp = opendir( dir.c_str() ) ) == NULL )
73+
{
74+
std::cerr << "Error(" << errno << ") opening " << dir << std::endl;
75+
return errno;
76+
}
77+
78+
while( ( dirp = readdir( dp ) ) != NULL )
79+
{
80+
const std::string filename( dirp->d_name );
81+
if( filename == "." || filename == ".." )
82+
continue;
83+
files.push_back( filename );
84+
}
85+
closedir( dp );
86+
#endif
87+
88+
return 0;
89+
}
90+
91+
}
92+
93+
#endif

0 commit comments

Comments
 (0)