MCPcopy Create free account
hub / github.com/alibaba/CicadaPlayer / sendMediaFrame

Method sendMediaFrame

framework/cacheModule/CacheManager.cpp:73–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73void CacheManager::sendMediaFrame(const IAFPacket *frame, StreamType type)
74{
75 if (!mNeedProcessFrame) {
76 return;
77 }
78
79 bool isMediaInfoSet = mCacheModule.isMediaInfoSet();
80
81 if (!isMediaInfoSet) {
82 int64_t streamSize = mDataSource->getStreamSize();
83 int64_t duration = mDataSource->getDuration();
84 mCacheModule.setMediaInfo(streamSize, duration);
85 vector<Stream_meta *> streamMetas{};
86 int metaRet = -1;
87 {
88 auto *videoMeta = static_cast<Stream_meta *>(malloc(sizeof(Stream_meta)));
89 memset(videoMeta, 0, sizeof(Stream_meta));
90 metaRet = mDataSource->getStreamMeta(videoMeta, StreamType::ST_TYPE_VIDEO);
91
92 if (metaRet == 0) {
93 videoMeta->type = Stream_type::STREAM_TYPE_VIDEO;
94 streamMetas.push_back(videoMeta);
95 }else {
96 releaseMeta(videoMeta);
97 free(videoMeta);
98 }
99 }
100 {
101 auto *audioMeta = static_cast<Stream_meta *>(malloc(sizeof(Stream_meta)));
102 memset(audioMeta, 0, sizeof(Stream_meta));
103 metaRet = mDataSource->getStreamMeta(audioMeta, StreamType::ST_TYPE_AUDIO);
104
105 if (metaRet == 0) {
106 audioMeta->type = Stream_type::STREAM_TYPE_AUDIO;
107 streamMetas.push_back(audioMeta);
108 } else {
109 releaseMeta(audioMeta);
110 free(audioMeta);
111 }
112 }
113 mCacheModule.setStreamMeta(streamMetas);
114 mCacheModule.setErrorCallback([this](int code, string msg) -> void{
115 AF_LOGE("cacheModule error : code = %d , msg = %s ", code, msg.c_str());
116 mNeedProcessFrame = false;
117
118 if (mCacheFailCallback != nullptr) {
119 mCacheFailCallback(code, msg);
120 }
121 });
122 mCacheModule.setResultCallback([this](bool success) -> void {
123 if (success) {
124 if (mCacheSuccessCallback != nullptr) {
125 mCacheSuccessCallback();
126 }
127 } else {
128 if (mCacheFailCallback != nullptr) {
129 mCacheFailCallback(-1, mStopReason);
130 }

Callers 1

mediaFrameCallbackMethod · 0.80

Calls 11

releaseMetaFunction · 0.85
isMediaInfoSetMethod · 0.80
getStreamSizeMethod · 0.80
getStreamMetaMethod · 0.80
getDurationMethod · 0.65
startMethod · 0.65
setMediaInfoMethod · 0.45
setStreamMetaMethod · 0.45
setErrorCallbackMethod · 0.45
setResultCallbackMethod · 0.45
addFrameMethod · 0.45

Tested by

no test coverage detected