"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp" between
xbmc-18.7.1-Leia.tar.gz and xbmc-18.8-Leia.tar.gz

About: XBMC is a software media player and entertainment hub for digital media that plays almost all popular audio and video formats around (new name "Kodi").

DVDVideoCodecAndroidMediaCodec.cpp  (xbmc-18.7.1-Leia):DVDVideoCodecAndroidMediaCodec.cpp  (xbmc-18.8-Leia)
skipping to change at line 789 skipping to change at line 789
{ {
m_videoBufferPool->ResetMediaCodec(); m_videoBufferPool->ResetMediaCodec();
m_videoBufferPool = nullptr; m_videoBufferPool = nullptr;
} }
m_videobuffer.iFlags = 0; m_videobuffer.iFlags = 0;
if (m_codec) if (m_codec)
{ {
m_codec->stop(); m_codec->stop();
xbmc_jnienv()->ExceptionClear();
m_codec->release(); m_codec->release();
xbmc_jnienv()->ExceptionClear();
m_codec = nullptr; m_codec = nullptr;
m_state = MEDIACODEC_STATE_STOPPED; m_state = MEDIACODEC_STATE_STOPPED;
} }
ReleaseSurfaceTexture(); ReleaseSurfaceTexture();
if (m_jnisurface) if (m_jnisurface)
m_jnisurface->release(); m_jnisurface->release();
m_jnisurface = nullptr; m_jnisurface = nullptr;
m_InstanceGuard.exchange(false); m_InstanceGuard.exchange(false);
skipping to change at line 834 skipping to change at line 836
pts = DVD_NOPTS_VALUE; pts = DVD_NOPTS_VALUE;
uint8_t *pData(packet.pData); uint8_t *pData(packet.pData);
size_t iSize(packet.iSize); size_t iSize(packet.iSize);
if (m_state == MEDIACODEC_STATE_ENDOFSTREAM) if (m_state == MEDIACODEC_STATE_ENDOFSTREAM)
{ {
// We received a packet but already reached EOS. Flush... // We received a packet but already reached EOS. Flush...
FlushInternal(); FlushInternal();
m_codec->flush(); m_codec->flush();
if (xbmc_jnienv()->ExceptionCheck())
{
xbmc_jnienv()->ExceptionClear();
CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::AddData: flush faile
d");
return false;
}
m_state = MEDIACODEC_STATE_FLUSHED; m_state = MEDIACODEC_STATE_FLUSHED;
} }
if (pData && iSize) if (pData && iSize)
{ {
if (m_indexInputBuffer >= 0) if (m_indexInputBuffer >= 0)
{ {
if (!(m_state == MEDIACODEC_STATE_FLUSHED || m_state == MEDIACODEC_STATE_R UNNING)) if (!(m_state == MEDIACODEC_STATE_FLUSHED || m_state == MEDIACODEC_STATE_R UNNING))
CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::AddData: Wrong sta te (%d)", m_state); CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::AddData: Wrong sta te (%d)", m_state);
skipping to change at line 875 skipping to change at line 883
} }
iSize = m_bitstream->GetConvertSize(); iSize = m_bitstream->GetConvertSize();
pData = m_bitstream->GetConvertBuffer(); pData = m_bitstream->GetConvertBuffer();
} }
if (m_state == MEDIACODEC_STATE_FLUSHED) if (m_state == MEDIACODEC_STATE_FLUSHED)
m_state = MEDIACODEC_STATE_RUNNING; m_state = MEDIACODEC_STATE_RUNNING;
CJNIByteBuffer buffer = m_codec->getInputBuffer(m_indexInputBuffer); CJNIByteBuffer buffer = m_codec->getInputBuffer(m_indexInputBuffer);
if (xbmc_jnienv()->ExceptionCheck())
{
xbmc_jnienv()->ExceptionClear();
CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::AddData: getInputB
uffer failed");
return false;
}
size_t out_size = buffer.capacity(); size_t out_size = buffer.capacity();
if ((size_t)iSize > out_size) if ((size_t)iSize > out_size)
{ {
CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::AddData, iSize(%d) > size(%d)", iSize, out_size); CLog::Log(LOGNOTICE, "CDVDVideoCodecAndroidMediaCodec::AddData: iSize(%d ) > size(%d)", iSize, out_size);
iSize = out_size; iSize = out_size;
} }
uint8_t* dst_ptr = (uint8_t*)xbmc_jnienv()->GetDirectBufferAddress(buffer. get_raw()); uint8_t* dst_ptr = (uint8_t*)xbmc_jnienv()->GetDirectBufferAddress(buffer. get_raw());
CJNIMediaCodecCryptoInfo* cryptoInfo(nullptr); CJNIMediaCodecCryptoInfo* cryptoInfo(nullptr);
if (m_crypto && packet.cryptoInfo) if (m_crypto && packet.cryptoInfo)
{ {
std::vector<int> clearBytes(packet.cryptoInfo->clearBytes, std::vector<int> clearBytes(packet.cryptoInfo->clearBytes,
packet.cryptoInfo->clearBytes + packet.cryptoInfo->clearBytes +
packet.cryptoInfo->numSubSamples); packet.cryptoInfo->numSubSamples);
skipping to change at line 960 skipping to change at line 975
if (!cryptoInfo) if (!cryptoInfo)
m_codec->queueInputBuffer(m_indexInputBuffer, offset, iSize, presentatio nTimeUs, flags); m_codec->queueInputBuffer(m_indexInputBuffer, offset, iSize, presentatio nTimeUs, flags);
else else
{ {
m_codec->queueSecureInputBuffer(m_indexInputBuffer, offset, *cryptoInfo, presentationTimeUs, m_codec->queueSecureInputBuffer(m_indexInputBuffer, offset, *cryptoInfo, presentationTimeUs,
flags); flags);
delete cryptoInfo, cryptoInfo = nullptr; delete cryptoInfo, cryptoInfo = nullptr;
} }
if (xbmc_jnienv()->ExceptionCheck()) if (xbmc_jnienv()->ExceptionCheck())
{ {
xbmc_jnienv()->ExceptionDescribe();
xbmc_jnienv()->ExceptionClear(); xbmc_jnienv()->ExceptionClear();
CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::AddData error"); CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::AddData error");
} }
m_indexInputBuffer = -1; m_indexInputBuffer = -1;
} }
else else
return false; return false;
} }
return true; return true;
} }
skipping to change at line 987 skipping to change at line 1001
if (m_codec) if (m_codec)
{ {
// flush all outputbuffers inflight, they will // flush all outputbuffers inflight, they will
// become invalid on m_codec->flush and generate // become invalid on m_codec->flush and generate
// a spew of java exceptions if used // a spew of java exceptions if used
FlushInternal(); FlushInternal();
// now we can flush the actual MediaCodec object // now we can flush the actual MediaCodec object
CLog::Log(LOGDEBUG, "CDVDVideoCodecAndroidMediaCodec::Reset Current state (% d)", m_state); CLog::Log(LOGDEBUG, "CDVDVideoCodecAndroidMediaCodec::Reset Current state (% d)", m_state);
m_state = MEDIACODEC_STATE_FLUSHED; m_state = MEDIACODEC_STATE_FLUSHED;
m_codec->flush(); m_codec->flush();
if (xbmc_jnienv()->ExceptionCheck())
{
xbmc_jnienv()->ExceptionClear();
CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::Reset: flush failed"
);
}
CJNIMediaFormat mediaFormat = m_codec->getOutputFormat(); CJNIMediaFormat mediaFormat = m_codec->getOutputFormat();
InjectExtraData(mediaFormat); if (xbmc_jnienv()->ExceptionCheck())
{
xbmc_jnienv()->ExceptionClear();
CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::Reset: getOutputForm
at failed");
}
else
InjectExtraData(mediaFormat);
// Invalidate our local VideoPicture bits // Invalidate our local VideoPicture bits
m_videobuffer.pts = DVD_NOPTS_VALUE; m_videobuffer.pts = DVD_NOPTS_VALUE;
m_indexInputBuffer = -1; m_indexInputBuffer = -1;
} }
} }
bool CDVDVideoCodecAndroidMediaCodec::Reconfigure(CDVDStreamInfo &hints) bool CDVDVideoCodecAndroidMediaCodec::Reconfigure(CDVDStreamInfo &hints)
{ {
CLog::Log(LOGDEBUG, "CDVDVideoCodecAndroidMediaCodec::Reconfigure called"); CLog::Log(LOGDEBUG, "CDVDVideoCodecAndroidMediaCodec::Reconfigure called");
return false; return false;
} }
CDVDVideoCodec::VCReturn CDVDVideoCodecAndroidMediaCodec::GetPicture(VideoPictur e* pVideoPicture) CDVDVideoCodec::VCReturn CDVDVideoCodecAndroidMediaCodec::GetPicture(VideoPictur e* pVideoPicture)
{ {
if (!m_opened) if (!m_opened)
return VC_NONE; return VC_NONE;
if (m_OutputDuration < m_fpsDuration || (m_codecControlFlags & DVD_CODEC_CTRL_ DRAIN)!=0) if (m_OutputDuration < m_fpsDuration || (m_codecControlFlags & DVD_CODEC_CTRL_ DRAIN) != 0)
{ {
m_videobuffer.videoBuffer = pVideoPicture->videoBuffer; m_videobuffer.videoBuffer = pVideoPicture->videoBuffer;
int retgp = GetOutputPicture(); int retgp = GetOutputPicture();
if (retgp > 0) if (retgp > 0)
{ {
m_noPictureLoop = 0; m_noPictureLoop = 0;
pVideoPicture->videoBuffer = nullptr; pVideoPicture->videoBuffer = nullptr;
skipping to change at line 1049 skipping to change at line 1075
} }
} }
} }
else else
m_OutputDuration = 0; m_OutputDuration = 0;
if ((m_codecControlFlags & DVD_CODEC_CTRL_DRAIN) == 0) if ((m_codecControlFlags & DVD_CODEC_CTRL_DRAIN) == 0)
{ {
// try to fetch an input buffer // try to fetch an input buffer
if (m_indexInputBuffer < 0) if (m_indexInputBuffer < 0)
{
m_indexInputBuffer = m_codec->dequeueInputBuffer(5000 /*timout*/); m_indexInputBuffer = m_codec->dequeueInputBuffer(5000 /*timout*/);
if (xbmc_jnienv()->ExceptionCheck())
{
xbmc_jnienv()->ExceptionClear();
CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::GetPicture dequeue
InputBuffer failed");
m_indexInputBuffer = -1;
}
}
if (m_indexInputBuffer >= 0) if (m_indexInputBuffer >= 0)
{ {
CLog::Log(LOGDEBUG, LOGVIDEO, "CDVDVideoCodecAndroidMediaCodec::GetPicture VC_BUFFER"); CLog::Log(LOGDEBUG, LOGVIDEO, "CDVDVideoCodecAndroidMediaCodec::GetPicture VC_BUFFER");
return VC_BUFFER; return VC_BUFFER;
} }
} }
return VC_NONE; return VC_NONE;
} }
skipping to change at line 1096 skipping to change at line 1130
if (m_codec && (m_state == MEDIACODEC_STATE_RUNNING || m_state == MEDIACODEC_S TATE_ENDOFSTREAM)) if (m_codec && (m_state == MEDIACODEC_STATE_RUNNING || m_state == MEDIACODEC_S TATE_ENDOFSTREAM))
{ {
// Release all mediaodec output buffers to allow drain if we don't get input buffer early // Release all mediaodec output buffers to allow drain if we don't get input buffer early
if (m_videoBufferPool) if (m_videoBufferPool)
{ {
CLog::Log(LOGDEBUG, "CDVDVideoCodecAndroidMediaCodec::%s: ReleaseMediaCode cBuffers", __func__); CLog::Log(LOGDEBUG, "CDVDVideoCodecAndroidMediaCodec::%s: ReleaseMediaCode cBuffers", __func__);
m_videoBufferPool->ReleaseMediaCodecBuffers(); m_videoBufferPool->ReleaseMediaCodecBuffers();
} }
if (m_indexInputBuffer < 0) if (m_indexInputBuffer < 0)
{
m_indexInputBuffer = m_codec->dequeueInputBuffer(100000); m_indexInputBuffer = m_codec->dequeueInputBuffer(100000);
if (xbmc_jnienv()->ExceptionCheck())
{
xbmc_jnienv()->ExceptionClear();
CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::SignalEndOfStream:
dequeueInputBuffer failed");
}
}
xbmc_jnienv()->ExceptionClear(); xbmc_jnienv()->ExceptionClear();
if (m_indexInputBuffer >= 0) if (m_indexInputBuffer >= 0)
{ {
m_codec->queueInputBuffer(m_indexInputBuffer, 0, 0, 0, m_codec->queueInputBuffer(m_indexInputBuffer, 0, 0, 0,
CJNIMediaCodec::BUFFER_FLAG_END_OF_STREAM); CJNIMediaCodec::BUFFER_FLAG_END_OF_STREAM);
if (xbmc_jnienv()->ExceptionCheck()) if (xbmc_jnienv()->ExceptionCheck())
{ {
xbmc_jnienv()->ExceptionClear(); xbmc_jnienv()->ExceptionClear();
CLog::Log(LOGWARNING, "CDVDVideoCodecAndroidMediaCodec::%s: queueInputBu CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::SignalEndOfStream:
ffer failed", queueInputBuffer failed");
__func__);
} }
else else
{ {
m_indexInputBuffer = -1; m_indexInputBuffer = -1;
CLog::Log(LOGDEBUG, "CDVDVideoCodecAndroidMediaCodec::%s: BUFFER_FLAG_EN D_OF_STREAM send", __func__); CLog::Log(LOGDEBUG, "CDVDVideoCodecAndroidMediaCodec::%s: BUFFER_FLAG_EN D_OF_STREAM send", __func__);
} }
} }
else else
CLog::Log(LOGWARNING, "CDVDVideoCodecAndroidMediaCodec::%s: invalid index: %d", __func__, m_indexInputBuffer); CLog::Log(LOGWARNING, "CDVDVideoCodecAndroidMediaCodec::%s: invalid index: %d", __func__, m_indexInputBuffer);
} }
skipping to change at line 1186 skipping to change at line 1227
else else
InitSurfaceTexture(); InitSurfaceTexture();
// configure and start the codec. // configure and start the codec.
// use the MediaFormat that we have setup. // use the MediaFormat that we have setup.
// use a null MediaCrypto, our content is not encrypted. // use a null MediaCrypto, our content is not encrypted.
int flags = 0; int flags = 0;
m_codec->configure(mediaformat, m_jnivideosurface, m_codec->configure(mediaformat, m_jnivideosurface,
m_crypto ? *m_crypto : CJNIMediaCrypto(jni::jhobject(NULL)) , flags); m_crypto ? *m_crypto : CJNIMediaCrypto(jni::jhobject(NULL)) , flags);
if (xbmc_jnienv()->ExceptionCheck()) if (xbmc_jnienv()->ExceptionCheck())
{ {
xbmc_jnienv()->ExceptionClear(); xbmc_jnienv()->ExceptionClear();
CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec configure error"); CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::ConfigureMediaCodec: c onfigure failed");
return false; return false;
} }
m_state = MEDIACODEC_STATE_CONFIGURED; m_state = MEDIACODEC_STATE_CONFIGURED;
m_codec->start(); m_codec->start();
if (xbmc_jnienv()->ExceptionCheck()) if (xbmc_jnienv()->ExceptionCheck())
{ {
xbmc_jnienv()->ExceptionClear(); xbmc_jnienv()->ExceptionClear();
Dispose(); Dispose();
CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec start error"); CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec:ConfigureMediaCodec: st art failed");
return false; return false;
} }
m_state = MEDIACODEC_STATE_FLUSHED; m_state = MEDIACODEC_STATE_FLUSHED;
// There is no guarantee we'll get an INFO_OUTPUT_FORMAT_CHANGED (up to Androi d 4.3) // There is no guarantee we'll get an INFO_OUTPUT_FORMAT_CHANGED (up to Androi d 4.3)
// Configure the output with defaults // Configure the output with defaults
ConfigureOutputFormat(mediaformat); ConfigureOutputFormat(mediaformat);
return true; return true;
} }
int CDVDVideoCodecAndroidMediaCodec::GetOutputPicture(void) int CDVDVideoCodecAndroidMediaCodec::GetOutputPicture(void)
{ {
int rtn = 0; int rtn = 0;
int64_t timeout_us = 10000; int64_t timeout_us = 10000;
CJNIMediaCodecBufferInfo bufferInfo; CJNIMediaCodecBufferInfo bufferInfo;
ssize_t index = m_codec->dequeueOutputBuffer(bufferInfo, timeout_us); ssize_t index = m_codec->dequeueOutputBuffer(bufferInfo, timeout_us);
if (xbmc_jnienv()->ExceptionCheck())
{
xbmc_jnienv()->ExceptionClear();
CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec:GetOutputPicture dequeu
eOutputBuffer failed");
return -2;
}
if (index >= 0) if (index >= 0)
{ {
int64_t pts = bufferInfo.presentationTimeUs(); int64_t pts = bufferInfo.presentationTimeUs();
m_videobuffer.dts = DVD_NOPTS_VALUE; m_videobuffer.dts = DVD_NOPTS_VALUE;
m_videobuffer.pts = DVD_NOPTS_VALUE; m_videobuffer.pts = DVD_NOPTS_VALUE;
if (pts != AV_NOPTS_VALUE) if (pts != AV_NOPTS_VALUE)
{ {
m_videobuffer.pts = pts; m_videobuffer.pts = pts;
m_videobuffer.pts += m_dtsShift; m_videobuffer.pts += m_dtsShift;
if (m_lastPTS >= 0 && pts > m_lastPTS) if (m_lastPTS >= 0 && pts > m_lastPTS)
m_OutputDuration += pts - m_lastPTS; m_OutputDuration += pts - m_lastPTS;
m_lastPTS = pts; m_lastPTS = pts;
} }
if (m_codecControlFlags & DVD_CODEC_CTRL_DROP) if (m_codecControlFlags & DVD_CODEC_CTRL_DROP)
{ {
m_noPictureLoop = 0; m_noPictureLoop = 0;
m_codec->releaseOutputBuffer(index, false); m_codec->releaseOutputBuffer(index, false);
if (xbmc_jnienv()->ExceptionCheck())
{
xbmc_jnienv()->ExceptionClear();
CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::GetOutputPicture:
releaseOutputBuffer (drop) failed");
}
return -2; return -2;
} }
int flags = bufferInfo.flags(); int flags = bufferInfo.flags();
if (flags & CJNIMediaCodec::BUFFER_FLAG_END_OF_STREAM) if (flags & CJNIMediaCodec::BUFFER_FLAG_END_OF_STREAM)
{ {
CLog::Log(LOGDEBUG, "CDVDVideoCodecAndroidMediaCodec:: BUFFER_FLAG_END_OF_ STREAM"); CLog::Log(LOGDEBUG, "CDVDVideoCodecAndroidMediaCodec:: BUFFER_FLAG_END_OF_ STREAM");
m_codec->releaseOutputBuffer(index, false); m_codec->releaseOutputBuffer(index, false);
if (xbmc_jnienv()->ExceptionCheck())
{
xbmc_jnienv()->ExceptionClear();
CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::GetOutputPicture:
releaseOutputBuffer (eof) failed");
}
return -1; return -1;
} }
if (m_videobuffer.videoBuffer) if (m_videobuffer.videoBuffer)
m_videobuffer.videoBuffer->Release(); m_videobuffer.videoBuffer->Release();
m_videobuffer.videoBuffer = m_videoBufferPool->Get(); m_videobuffer.videoBuffer = m_videoBufferPool->Get();
static_cast<CMediaCodecVideoBuffer*>(m_videobuffer.videoBuffer)->Set(index, m_textureId, m_surfaceTexture, m_frameAvailable, m_jnivideoview); static_cast<CMediaCodecVideoBuffer*>(m_videobuffer.videoBuffer)->Set(index, m_textureId, m_surfaceTexture, m_frameAvailable, m_jnivideoview);
rtn = 1; rtn = 1;
skipping to change at line 1455 skipping to change at line 1511
} }
void CDVDVideoCodecAndroidMediaCodec::surfaceDestroyed(CJNISurfaceHolder holder) void CDVDVideoCodecAndroidMediaCodec::surfaceDestroyed(CJNISurfaceHolder holder)
{ {
if (m_state != MEDIACODEC_STATE_STOPPED && m_state != MEDIACODEC_STATE_UNINITI ALIZED) if (m_state != MEDIACODEC_STATE_STOPPED && m_state != MEDIACODEC_STATE_UNINITI ALIZED)
{ {
m_state = MEDIACODEC_STATE_STOPPED; m_state = MEDIACODEC_STATE_STOPPED;
if (m_jnisurface) if (m_jnisurface)
m_jnisurface->release(); m_jnisurface->release();
m_codec->stop(); m_codec->stop();
xbmc_jnienv()->ExceptionClear();
} }
} }
 End of changes. 25 change blocks. 
12 lines changed or deleted 78 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)