@@ -34,159 +34,192 @@ Transcoder::~Transcoder()
34
34
35
35
void Transcoder::add ( const std::string& filename, const size_t streamIndex, const std::string& profileName, const size_t offset )
36
36
{
37
- if ( profileName.length () == 0 ) // no profile, only re-wrap stream
37
+ // Re-wrap
38
+ if ( profileName.length () == 0 )
38
39
{
39
40
if ( _verbose )
40
- std::cout << " add re-wrap stream" << std::endl;
41
+ std::cout << " Add re-wrap stream" << std::endl;
42
+
43
+ // Check filename
44
+ if ( filename.length () == 0 )
45
+ throw std::runtime_error ( " Can't re-wrap a stream without filename indicated" );
46
+
41
47
addRewrapStream ( filename, streamIndex );
42
- return ;
43
48
}
44
-
45
- ProfileLoader::Profile& transcodeProfile = _profileLoader.getProfile ( profileName );
46
- add ( filename, streamIndex, transcodeProfile, offset );
49
+ // Transcode
50
+ else
51
+ {
52
+ ProfileLoader::Profile& transcodeProfile = _profileLoader.getProfile ( profileName );
53
+ add ( filename, streamIndex, transcodeProfile, offset );
54
+ }
47
55
}
48
56
49
57
void Transcoder::add ( const std::string& filename, const size_t streamIndex, const std::string& profileName, ICodec& codec, const size_t offset )
50
58
{
51
- if ( profileName.length () == 0 ) // no profile, only re-wrap stream
59
+ // Re-wrap
60
+ if ( profileName.length () == 0 )
52
61
{
53
62
if ( _verbose )
54
- std::cout << " add re-wrap stream" << std::endl;
55
-
63
+ std::cout << " Add re-wrap stream" << std::endl;
64
+
65
+ // Check filename
56
66
if ( filename.length () == 0 )
57
- {
58
- std::cerr << " can't add a generated stream with no profileName indicated" << std::endl;
59
- return ;
60
- }
67
+ throw std::runtime_error ( " Can't re-wrap a stream without filename indicated" );
61
68
62
69
addRewrapStream ( filename, streamIndex );
63
- return ;
64
70
}
65
-
66
- ProfileLoader::Profile& transcodeProfile = _profileLoader.getProfile ( profileName );
67
- add ( filename, streamIndex, transcodeProfile, codec, offset );
71
+ // Transcode
72
+ else
73
+ {
74
+ ProfileLoader::Profile& transcodeProfile = _profileLoader.getProfile ( profileName );
75
+ add ( filename, streamIndex, transcodeProfile, codec, offset );
76
+ }
68
77
}
69
78
70
79
void Transcoder::add ( const std::string& filename, const size_t streamIndex, ProfileLoader::Profile& profile, const size_t offset )
71
80
{
81
+ // Add profile if new
72
82
_profileLoader.update ( profile );
83
+
84
+ // Check filename
73
85
if ( ! filename.length () )
74
86
{
75
- std::cerr << " can't add a stream with no filename indicated" << std::endl;
76
- return ;
87
+ throw std::runtime_error ( " Can't transcode a stream without filename indicated" );
77
88
}
78
89
79
90
if ( _verbose )
80
- std::cout << " add transcoding stream" << std::endl;
91
+ std::cout << " Add transcoded stream" << std::endl;
81
92
addTranscodeStream ( filename, streamIndex, profile, offset );
82
93
}
83
94
84
95
void Transcoder::add ( const std::string& filename, const size_t streamIndex, ProfileLoader::Profile& profile, ICodec& codec, const size_t offset )
85
96
{
97
+ // Add profile if new
86
98
_profileLoader.update ( profile );
99
+
100
+ // Generator
87
101
if ( ! filename.length () )
88
102
{
89
103
if ( _verbose )
90
- std::cout << " add a generated stream" << std::endl;
104
+ std::cout << " Add generated stream" << std::endl;
91
105
addDummyStream ( profile, codec );
92
- return ;
93
106
}
94
-
95
- if ( _verbose )
96
- std::cout << " add transcoding stream" << std::endl;
97
- addTranscodeStream ( filename, streamIndex, profile, offset );
107
+ // Transcode
108
+ else
109
+ {
110
+ if ( _verbose )
111
+ std::cout << " Add transcoded stream" << std::endl;
112
+ addTranscodeStream ( filename, streamIndex, profile, offset );
113
+ }
98
114
}
99
115
100
116
void Transcoder::add ( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const std::string& profileName, const size_t offset )
101
117
{
118
+ // No subStream selected
102
119
if ( subStreamIndex < 0 )
103
120
{
104
121
add ( filename, streamIndex, profileName, offset );
105
122
return ;
106
123
}
107
124
108
- if ( profileName.length () == 0 ) // no profile, only re-wrap stream
125
+ if ( profileName.length () == 0 )
109
126
{
110
- if ( _verbose )
111
- std::cout << " add re-wrap stream for substream " << subStreamIndex << std::endl;
112
-
113
- addRewrapStream ( filename, streamIndex );
114
- return ;
127
+ // Re-wrap
128
+ if ( subStreamIndex < 0 )
129
+ {
130
+ if ( _verbose )
131
+ std::cout << " Add re-wrap stream" << std::endl;
132
+ addRewrapStream ( filename, streamIndex );
133
+ return ;
134
+ }
135
+ else
136
+ throw std::runtime_error ( " Can't demultiplexing and re-wrap a stream" );
137
+ }
138
+ // Transcode
139
+ else
140
+ {
141
+ ProfileLoader::Profile& transcodeProfile = _profileLoader.getProfile ( profileName );
142
+ add ( filename, streamIndex, subStreamIndex, transcodeProfile, offset );
115
143
}
116
-
117
- ProfileLoader::Profile& transcodeProfile = _profileLoader.getProfile ( profileName );
118
- add ( filename, streamIndex, subStreamIndex, transcodeProfile, offset );
119
144
}
120
145
121
146
void Transcoder::add ( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const std::string& profileName, ICodec& codec, const size_t offset )
122
147
{
148
+ // No subStream selected
123
149
if ( subStreamIndex < 0 )
124
150
{
125
151
add ( filename, streamIndex, profileName, codec );
126
152
return ;
127
153
}
128
-
129
- if ( profileName.length () == 0 ) // no profile, only re-wrap stream
130
- {
131
- if ( _verbose )
132
- std::cout << " add re-wrap stream for substream " << subStreamIndex << std::endl;
133
154
134
- if ( filename.length () == 0 )
155
+ // Re-wrap
156
+ if ( profileName.length () == 0 )
157
+ {
158
+ // Re-wrap
159
+ if ( subStreamIndex < 0 )
135
160
{
136
- std::cerr << " can't add a generated stream with no profileName indicated" << std::endl;
161
+ if ( _verbose )
162
+ std::cout << " Add re-wrap stream" << std::endl;
163
+ addRewrapStream ( filename, streamIndex );
137
164
return ;
138
165
}
139
-
140
- addRewrapStream ( filename, streamIndex );
141
- return ;
166
+ else
167
+ throw std::runtime_error ( " Can't demultiplexing and re-wrap a stream" );
168
+ }
169
+ // Transcode
170
+ else
171
+ {
172
+ ProfileLoader::Profile& transcodeProfile = _profileLoader.getProfile ( profileName );
173
+ add ( filename, streamIndex, subStreamIndex, transcodeProfile, codec, offset );
142
174
}
143
-
144
- ProfileLoader::Profile& transcodeProfile = _profileLoader.getProfile ( profileName );
145
- add ( filename, streamIndex, subStreamIndex, transcodeProfile, codec, offset );
146
175
}
147
176
148
177
void Transcoder::add ( const std::string& filename, const size_t streamIndex, const int subStreamIndex, ProfileLoader::Profile& profile, const size_t offset )
149
178
{
179
+ // Add profile if new
150
180
_profileLoader.update ( profile );
151
-
181
+
182
+ // No subStream selected
152
183
if ( subStreamIndex < 0 )
153
184
{
154
185
add ( filename, streamIndex, profile, offset );
155
186
return ;
156
187
}
157
-
188
+
189
+ // Check filename
158
190
if ( ! filename.length () )
159
191
{
160
- if ( _verbose )
161
- std::cerr << " can't add a stream with no filename indicated" << std::endl;
162
- return ;
192
+ throw std::runtime_error ( " Can't transcode a stream without filename indicated" );
163
193
}
164
194
165
195
if ( _verbose )
166
- std::cout << " add transcoding stream for substream " << subStreamIndex << std::endl;
196
+ std::cout << " Add transcoded for substream " << subStreamIndex << std::endl;
167
197
addTranscodeStream ( filename, streamIndex, subStreamIndex, profile, offset );
168
198
}
169
199
170
200
void Transcoder::add ( const std::string& filename, const size_t streamIndex, const int subStreamIndex, ProfileLoader::Profile& profile, ICodec& codec, const size_t offset )
171
201
{
202
+ // Add profile if new
172
203
_profileLoader.update ( profile );
173
204
205
+ // No subStream selected
174
206
if ( subStreamIndex < 0 )
175
207
{
176
208
add ( filename, streamIndex, profile );
177
209
return ;
178
210
}
179
-
211
+
212
+ // Generator
180
213
if ( ! filename.length () )
181
214
{
182
215
if ( _verbose )
183
- std::cout << " add a generated stream" << std::endl;
216
+ std::cout << " Add generated stream" << std::endl;
184
217
addDummyStream ( profile, codec );
185
218
return ;
186
219
}
187
220
188
221
if ( _verbose )
189
- std::cout << " add transcoding stream for substream " << subStreamIndex << std::endl;
222
+ std::cout << " Add transcoded stream for substream " << subStreamIndex << std::endl;
190
223
addTranscodeStream ( filename, streamIndex, subStreamIndex, profile, offset );
191
224
}
192
225
0 commit comments