File tree Expand file tree Collapse file tree 2 files changed +17
-10
lines changed Expand file tree Collapse file tree 2 files changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ AvInputStream& InputFile::getStream( size_t index )
144
144
return *_inputStreams.at ( index );
145
145
}
146
146
147
- bool InputFile::readNextPacket ( const size_t streamIndex )
147
+ bool InputFile::readNextPacket ( CodedData& data, const size_t streamIndex )
148
148
{
149
149
AVPacket packet;
150
150
av_init_packet ( &packet );
@@ -157,15 +157,21 @@ bool InputFile::readNextPacket( const size_t streamIndex )
157
157
return false ;
158
158
}
159
159
160
- // send packet to stream buffer
161
- _inputStreams.at ( packet.stream_index )->addPacket ( packet );
162
-
163
- // We only read one stream and skip others
160
+ // if the packet stream is the expected one
161
+ // copy and return the packet data
164
162
if ( packet.stream_index == (int )streamIndex )
165
163
{
164
+ data.getBuffer ().resize ( packet.size );
165
+ if ( packet.size != 0 )
166
+ memcpy ( data.getPtr (), packet.data , packet.size );
166
167
av_free_packet ( &packet );
167
168
return true ;
168
169
}
170
+ // else add the packet data to the stream cache
171
+ else
172
+ {
173
+ _inputStreams.at ( packet.stream_index )->addPacket ( packet );
174
+ }
169
175
170
176
// do not delete these 2 lines
171
177
// need to skip packet, delete this one and re-init for reading the next one
Original file line number Diff line number Diff line change @@ -86,16 +86,17 @@ class AvExport InputFile
86
86
AVFormatContext& getFormatContext () const { return *_formatContext; }
87
87
88
88
/* *
89
- * @brief Read the next packet for the specified stream
90
- * @note For performances, each readed stream needs to be bufferized using the readStream() method.
91
- * @return if next packet was succefully readed
89
+ * @brief Read the next packet of the specified stream
90
+ * @param data: data of next packet read
91
+ * @note For performances, each read stream needs to be bufferized using the readStream() method.
92
+ * @return if next packet was succefully read
92
93
**/
93
- bool readNextPacket ( const size_t streamIndex );
94
+ bool readNextPacket ( CodedData& data, const size_t streamIndex );
94
95
95
96
/* *
96
97
* @brief Seek input stream at specified frame
97
98
* @note clean also buffers in each InputStream
98
- * @return if next packet was succefully readed
99
+ * @return if next packet was succefully read
99
100
**/
100
101
void seekAtFrame ( const size_t frame );
101
102
You can’t perform that action at this time.
0 commit comments