29 static const char *IsoBmffProcessorTypeName[] =
38 : p_aamp(aamp), type(trackType), peerProcessor(peerBmffProcessor), basePTS(0),
39 processPTSComplete(false), timeScale(0), initSegment(),
40 playRate(1.0f), abortAll(false), m_mutex(), m_cond(),
41 initSegmentProcessComplete(false),
44 AAMPLOG_WARN(
"IsoBmffProcessor:: Created IsoBmffProcessor(%p) for type:%d and peerProcessor(%p)",
this, type, peerBmffProcessor);
49 pthread_mutex_init(&m_mutex, NULL);
50 pthread_cond_init(&m_cond, NULL);
53 initSegment.reserve(2);
62 pthread_mutex_destroy(&m_mutex);
63 pthread_cond_destroy(&m_cond);
74 AAMPLOG_TRACE(
"IsoBmffProcessor:: [%s] sending segment at pos:%f dur:%f", IsoBmffProcessorTypeName[type], position, duration);
77 if (type == eBMFFPROCESSOR_TYPE_AUDIO)
79 if (!processPTSComplete)
82 buffer.setBuffer((uint8_t *)segment, size);
85 if (buffer.isInitSegment())
93 pthread_mutex_lock(&m_mutex);
94 if (!processPTSComplete)
96 AAMPLOG_INFO(
"IsoBmffProcessor:: [%s] Going into wait for PTS processing to complete", IsoBmffProcessorTypeName[type]);
97 pthread_cond_wait(&m_cond, &m_mutex);
103 pthread_mutex_unlock(&m_mutex);
106 if (ret && !initSegmentProcessComplete)
108 if (processPTSComplete)
110 double pos = ((double)basePTS / (
double)timeScale);
111 if (!initSegment.empty())
122 initSegmentProcessComplete =
true;
131 if (ret && !processPTSComplete && playRate == AAMP_NORMAL_PLAY_RATE)
135 buffer.setBuffer((uint8_t *)segment, size);
136 buffer.parseBuffer();
138 if (buffer.isInitSegment())
141 if (buffer.getTimeScale(tScale))
144 AAMPLOG_INFO(
"IsoBmffProcessor:: [%s] TimeScale (%u) set", IsoBmffProcessorTypeName[type], timeScale);
154 if (buffer.getFirstPTS(fPts))
157 processPTSComplete =
true;
158 AAMPLOG_WARN(
"IsoBmffProcessor:: [%s] Base PTS (%lld) set", IsoBmffProcessorTypeName[type], basePTS);
162 AAMPLOG_ERR(
"IsoBmffProcessor:: [%s] Failed to process pts from buffer at pos:%f and dur:%f", IsoBmffProcessorTypeName[type], position, duration);
165 pthread_mutex_lock(&m_mutex);
170 pthread_mutex_unlock(&m_mutex);
172 if (ret && processPTSComplete)
176 if (initSegment.empty())
178 AAMPLOG_WARN(
"IsoBmffProcessor:: [%s] Init segment missing during PTS processing!", IsoBmffProcessorTypeName[type]);
184 AAMPLOG_WARN(
"IsoBmffProcessor:: [%s] MDHD/MVHD boxes are missing in init segment!", IsoBmffProcessorTypeName[type]);
186 if (buffer.getTimeScale(tScale))
189 AAMPLOG_INFO(
"IsoBmffProcessor:: [%s] TimeScale (%u) set", IsoBmffProcessorTypeName[type], timeScale);
193 AAMPLOG_ERR(
"IsoBmffProcessor:: [%s] TimeScale value missing in init segment and mp4 fragment, setting to a default of 1!", IsoBmffProcessorTypeName[type]);
202 double pos = ((double)basePTS / (
double)timeScale);
205 #ifdef ENABLE_AAMP_QTDEMUX_OVERRIDE
211 if (type == eBMFFPROCESSOR_TYPE_VIDEO)
220 peerProcessor->
setBasePTS(basePTS, timeScale);
224 initSegmentProcessComplete =
true;
243 pthread_mutex_lock(&m_mutex);
245 pthread_cond_signal(&m_cond);
246 pthread_mutex_unlock(&m_mutex);
256 pthread_mutex_lock(&m_mutex);
259 processPTSComplete =
false;
261 initSegmentProcessComplete =
false;
262 pthread_mutex_unlock(&m_mutex);
278 AAMPLOG_WARN(
"[%s] Base PTS (%lld) and TimeScale (%u) set", IsoBmffProcessorTypeName[type], pts, tScale);
279 pthread_mutex_lock(&m_mutex);
282 processPTSComplete =
true;
283 pthread_cond_signal(&m_cond);
284 pthread_mutex_unlock(&m_mutex);
293 AAMPLOG_INFO(
"IsoBmffProcessor::[%s] Caching init fragment", IsoBmffProcessorTypeName[type]);
297 initSegment.push_back(buffer);
307 AAMPLOG_WARN(
"IsoBmffProcessor:: [%s] Push init fragment", IsoBmffProcessorTypeName[type]);
308 if (initSegment.size() > 0)
310 for (
auto it = initSegment.begin(); it != initSegment.end();)
316 it = initSegment.erase(it);
326 if (initSegment.size() > 0)
328 for (
auto it = initSegment.begin(); it != initSegment.end();)
333 it = initSegment.erase(it);