Skip to content

Commit e3a4851

Browse files
unify split char* and start to get env for profiles
1 parent 03d771b commit e3a4851

File tree

5 files changed

+33
-35
lines changed

5 files changed

+33
-35
lines changed

src/AvTranscoder/Description.hpp

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ extern "C" {
1313
#include <cstring>
1414
#include <algorithm> //sort, unique
1515

16+
#include "common.hpp"
17+
1618
namespace avtranscoder
1719
{
1820

@@ -38,23 +40,11 @@ std::vector<std::string> getInputExtensions()
3840
if( iFormat->extensions != NULL )
3941
{
4042
// parse extensions
41-
std::string exts = std::string( iFormat->extensions );
42-
char* ext = strtok( const_cast<char*>( exts.c_str() ), "," );
43-
while( ext != NULL )
44-
{
45-
extensions.push_back( std::string( ext ) );
46-
ext = strtok( NULL, "," );
47-
}
43+
split( extensions, std::string( iFormat->extensions ), "," );
4844

4945
// parse name (name's format defines (in general) extensions )
5046
// don't need to do it in recent LibAV/FFMpeg versions
51-
exts = std::string( iFormat->name );
52-
ext = strtok( const_cast<char*>( exts.c_str() ), "," );
53-
while( ext != NULL )
54-
{
55-
extensions.push_back( std::string( ext ) );
56-
ext = strtok( NULL, "," );
57-
}
47+
split( extensions, std::string( iFormat->name ), "," );
5848
}
5949
}
6050
// sort
@@ -77,23 +67,11 @@ std::vector<std::string> getOutputExtensions()
7767
if( oFormat->extensions != NULL )
7868
{
7969
// parse extensions
80-
std::string exts = std::string( oFormat->extensions );
81-
char* ext = strtok( const_cast<char*>( exts.c_str() ), "," );
82-
while( ext != NULL )
83-
{
84-
extensions.push_back( std::string( ext ) );
85-
ext = strtok( NULL, "," );
86-
}
70+
split( extensions, std::string( oFormat->extensions ), "," );
8771

8872
// parse name (name's format defines (in general) extensions )
8973
// don't need to do it in recent LibAV/FFMpeg versions
90-
exts = std::string( oFormat->name );
91-
ext = strtok( const_cast<char*>( exts.c_str() ), "," );
92-
while( ext != NULL )
93-
{
94-
extensions.push_back( std::string( ext ) );
95-
ext = strtok( NULL, "," );
96-
}
74+
split( extensions, std::string( oFormat->name ), "," );
9775
}
9876
}
9977
// sort

src/AvTranscoder/OutputStreamAudio.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ bool OutputStreamAudio::encodeFrame( DataStream& codedFrame )
169169
void OutputStreamAudio::setProfile( const std::string& profile )
170170
{
171171
Profile p;
172-
p.loadAudioProfiles();
172+
p.loadProfiles();
173173
Profile::ProfileDesc profDesc = p.getProfile( profile );
174174

175175
_audioDesc.setAudioCodec( profDesc["codec"] );

src/AvTranscoder/Profile.cpp

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
#include "Profile.hpp"
22

3+
#include <AvTranscoder/common.hpp>
4+
35
#include <AvTranscoder/Profiles/XdCamHd422.hpp>
46
#include <AvTranscoder/Profiles/DNxHD.hpp>
57
#include <AvTranscoder/Profiles/Wave.hpp>
68

9+
#include <iostream>
10+
#include <cstdlib>
11+
712
namespace avtranscoder
813
{
914

@@ -23,11 +28,17 @@ void Profile::loadProfiles()
2328
{
2429
loadXdCamHD422( _profiles );
2530
loadDNxHD( _profiles );
26-
}
27-
28-
void Profile::loadAudioProfiles()
29-
{
3031
loadWave( _profiles );
32+
33+
if( const char* envAvProfiles = std::getenv("AVPROFILES") )
34+
{
35+
std::vector< std::string > paths;
36+
split( paths, envAvProfiles, ";" );
37+
for( std::vector< std::string >::iterator it = paths.begin(); it != paths.end(); ++it )
38+
{
39+
std::cout << "search profile in path " << *it << std::endl;
40+
}
41+
}
3142
}
3243

3344
const Profile::ProfilesDesc& Profile::getProfiles()
@@ -39,6 +50,12 @@ Profile::ProfilesDesc Profile::getVideoProfiles()
3950
{
4051
ProfilesDesc profiles;
4152

53+
for( ProfilesDesc::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
54+
{
55+
if( (*it).find( avProfilType )->second == avProfilTypeVideo )
56+
profiles.push_back( *it );
57+
}
58+
4259
return profiles;
4360
}
4461

@@ -53,7 +70,7 @@ Profile::ProfileDesc& Profile::getProfile( const std::string& searchProfile )
5370
{
5471
for( ProfilesDesc::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
5572
{
56-
if( (*it)["avProfile"] == searchProfile )
73+
if( (*it).find( avProfilIdentificator )->second == searchProfile )
5774
{
5875
return (*it);
5976
}

src/AvTranscoder/Profile.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class Profile
2626
Profile();
2727

2828
void loadProfiles();
29-
void loadAudioProfiles();
3029

3130
const ProfilesDesc& getProfiles();
3231

src/AvTranscoder/common.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ extern "C" {
1515
}
1616

1717
#include <string>
18+
#include <cstring>
19+
#include <vector>
1820

1921
#ifdef SWIG
2022
#define AvExport
@@ -57,6 +59,8 @@ struct Ratio
5759
size_t den;
5860
};
5961

62+
void split( std::vector< std::string >& splitedString, const std::string& inputString, const std::string& splitChars = ";" );
63+
6064
}
6165

6266
#endif

0 commit comments

Comments
 (0)