Skip to content

Commit

Permalink
fix(demuxer): Prevent StreamMeta being nullptr
Browse files Browse the repository at this point in the history
  • Loading branch information
I-m-SuperMan committed Apr 8, 2020
1 parent 31813cc commit 036f137
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion framework/cacheModule/cache/CacheFileRemuxer.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private :
function<void(int, string)> mErrorCallback = nullptr;
function<void(bool)> mResultCallback = nullptr;

const vector<Stream_meta*> *mStreamMetas;
const vector<Stream_meta*> *mStreamMetas = nullptr;

};

Expand Down
2 changes: 1 addition & 1 deletion framework/muxer/IMuxer.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class IMuxer {
* add streamMetas
* @param streamMetas
*/
virtual void setStreamMetas(const vector<Stream_meta*> *streamMetas) = 0;
virtual void setStreamMetas(const std::vector<Stream_meta*> *streamMetas) = 0;

//must be set before open(). These will be write to header.
virtual void addSourceMetas(std::map<std::string,std::string> sourceMetas) = 0;
Expand Down
28 changes: 15 additions & 13 deletions framework/muxer/ffmpegMuxer/FfmpegMuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,22 @@ int FfmpegMuxer::open()
return ret;
}

for (Stream_meta *item : *mStreamMetas) {
AVStream *stream = nullptr;

if (item->type == Stream_type::STREAM_TYPE_VIDEO) {
stream = avformat_new_stream(mDestFormatContext, nullptr);
MetaToCodec::videoMetaToStream(stream, item);
check_codec_tag(stream);
} else if (item->type == Stream_type::STREAM_TYPE_AUDIO) {
stream = avformat_new_stream(mDestFormatContext, nullptr);
MetaToCodec::audioMetaToStream(stream, item);
check_codec_tag(stream);
}
if(mStreamMetas != nullptr ) {
for (Stream_meta *item : *mStreamMetas) {
AVStream *stream = nullptr;

if (item->type == Stream_type::STREAM_TYPE_VIDEO) {
stream = avformat_new_stream(mDestFormatContext, nullptr);
MetaToCodec::videoMetaToStream(stream, item);
check_codec_tag(stream);
} else if (item->type == Stream_type::STREAM_TYPE_AUDIO) {
stream = avformat_new_stream(mDestFormatContext, nullptr);
MetaToCodec::audioMetaToStream(stream, item);
check_codec_tag(stream);
}

insertStreamInfo(stream, item);
insertStreamInfo(stream, item);
}
}

if (mOpenFunc != nullptr) {
Expand Down
4 changes: 2 additions & 2 deletions framework/muxer/ffmpegMuxer/FfmpegMuxer.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CICADA_CPLUS_EXTERN FfmpegMuxer : public IMuxer, private IMuxerPrototype {

void setCopyPts(bool copyPts) override;

void setStreamMetas(const vector<Stream_meta*> *streamMetas) override;
void setStreamMetas(const std::vector<Stream_meta*> *streamMetas) override;

//must be set before open(). These will be write to header.
void addSourceMetas(std::map<std::string, std::string> sourceMetas) override;
Expand Down Expand Up @@ -118,7 +118,7 @@ class CICADA_CPLUS_EXTERN FfmpegMuxer : public IMuxer, private IMuxerPrototype {
private:

std::map<std::string, std::string> mSourceMetaMap;
const vector<Stream_meta*> *mStreamMetas;
const std::vector<Stream_meta*> *mStreamMetas = nullptr;
std::map<int, StreamInfo> mStreamInfoMap;

uint8_t *mIobuf = nullptr;
Expand Down

0 comments on commit 036f137

Please sign in to comment.