[DEV] display film correctly not seek for now

This commit is contained in:
Edouard DUPIN 2017-02-09 23:31:54 +01:00
parent 27e0a4e603
commit 3b0a4cd27c
5 changed files with 278 additions and 130 deletions

View File

@ -213,7 +213,7 @@ int appl::MediaDecoder::decode_packet(int *_gotFrame, int _cached) {
m_seekApply = m_currentVideoTime; // => ready to display m_seekApply = m_currentVideoTime; // => ready to display
} }
echrono::Duration packetTime(double(m_frame->pkt_pts) * double(m_videoDecoderContext->time_base.num) / double(m_videoDecoderContext->time_base.den)); echrono::Duration packetTime(double(m_frame->pkt_pts) * double(m_videoDecoderContext->time_base.num) / double(m_videoDecoderContext->time_base.den));
APPL_INFO("video_frame " << (_cached?"(cached)":"") APPL_VERBOSE("video_frame " << (_cached?"(cached)":"")
<< " n=" << m_videoFrameCount << " n=" << m_videoFrameCount
<< " coded_n=" << m_frame->coded_picture_number << " coded_n=" << m_frame->coded_picture_number
<< " pts=" << av_ts2timestr(m_frame->pkt_pts, &m_videoDecoderContext->time_base) << " " << packetTime); << " pts=" << av_ts2timestr(m_frame->pkt_pts, &m_videoDecoderContext->time_base) << " " << packetTime);
@ -253,7 +253,7 @@ int appl::MediaDecoder::decode_packet(int *_gotFrame, int _cached) {
// seek specific usecase ==> drop frame to have fast display // seek specific usecase ==> drop frame to have fast display
m_currentAudioTime = packetTime; m_currentAudioTime = packetTime;
} else { } else {
APPL_INFO("audio_frame " << (_cached?"(cached)":"") APPL_VERBOSE("audio_frame " << (_cached?"(cached)":"")
<< " n=" << m_audioFrameCount << " n=" << m_audioFrameCount
<< " nb_samples=" << m_frame->nb_samples << " nb_samples=" << m_frame->nb_samples
<< " pts=" << packetTime); << " pts=" << packetTime);
@ -354,159 +354,279 @@ void appl::MediaDecoder::init(ememory::SharedPtr<ClientProperty> _property, uint
APPL_ERROR("Request play of not connected handle ==> 'not alive'"); APPL_ERROR("Request play of not connected handle ==> 'not alive'");
return; return;
} }
APPL_ERROR("AAAAAAAAAAAA");
zeus::service::ProxyVideo remoteServiceVideo = _property->connection.getService("video"); zeus::service::ProxyVideo remoteServiceVideo = _property->connection.getService("video");
// remove all media (for test) // remove all media (for test)
if (remoteServiceVideo.exist() == false) { if (remoteServiceVideo.exist() == false) {
APPL_ERROR("Video service is ==> 'not alive'"); APPL_ERROR("Video service is ==> 'not alive'");
return; return;
} }
m_remoteFileHandle = remoteServiceVideo.mediaGet(_mediaId).wait().get(); APPL_ERROR("AAAA 222");
m_remote = ememory::makeShared<appl::StreamBuffering>();
std::string mimeType = m_remoteFileHandle.getMineType().wait().get(); m_remote->m_bufferReadPosition = 0;
uint64_t fileSize = m_remoteFileHandle.getSize().wait().get(); m_remote->m_property = _property;
// pre-allcocate data file size: m_remote->m_mediaId = _mediaId;
m_remoteBuffer.resize(fileSize, 0); APPL_ERROR("AAAA 333");
// start with loading of 1 Mo remoteServiceVideo.mediaGet(_mediaId).andThen(
auto futData = m_remoteFileHandle.getPart(0, BUFFER_SIZE_GET_SLOT); [=](zeus::Future<zeus::ProxyFile> _fut) mutable {
futData.wait(); APPL_ERROR("Receive ProxyFile");
if (futData.hasError() == true) { m_remote->m_fileHandle = _fut.get();
APPL_ERROR("Error when loading data (First 1 MB)"); m_remote->m_fileHandle.getSize().andThen(
} [=](zeus::Future<uint64_t> _fut) mutable {
zeus::Raw buffer = futData.get(); APPL_ERROR("Receive FileSize to index property");
memcpy(&m_remoteBuffer[0], buffer.data(), buffer.size()); m_remote->m_buffer.resize(_fut.get(), 0);
m_remoteBufferFillSection.push_back(std::pair<uint32_t,uint32_t>(0,buffer.size())); m_remote->checkIfWeNeedMoreDataFromNetwork();
m_remoteBufferReadPosition = 0; return true;
m_remoteProperty = _property; });
m_remoteMediaId = _mediaId; return true;
});
// create temporary file: init();
/*
etk::FSNode tmpFile("CACHE:videoPlayer." + zeus::getExtention(mimeType));
APPL_WARNING("Store in tmpFile : " << tmpFile << " ==> " << tmpFile.getName());
std::string sha512String = zeus::storeInFile(dataFile, tmpFile.getName());
APPL_WARNING("Store in tmpFile : " << tmpFile << " ==> " << tmpFile.getFileSystemName() << " DONE");
init(tmpFile.getFileSystemName());
*/
init("");
// TODO : init(tmpFile);
} }
int appl::MediaDecoder::readFunc(uint8_t* _buf, int _bufSize) { int appl::MediaDecoder::readFunc(uint8_t* _buf, int _bufSize) {
APPL_ERROR("call read ... " << m_remoteBufferReadPosition << " size=" << _bufSize); APPL_ERROR("call read ... " << m_remote->m_bufferReadPosition << " size=" << _bufSize);
// check if enought data: // check if enought data:
bool find = false; int64_t readableSize = m_remote->sizeReadable();
for (auto &it : m_remoteBufferFillSection) { if (_bufSize > readableSize) {
if ( m_remoteBufferReadPosition >= it.first _bufSize = readableSize;
&& m_remoteBufferReadPosition < it.second) {
find = true;
// part already download...
if (it.second - m_remoteBufferReadPosition < _bufSize) {
// missing data ==> reduce copy size
_bufSize = it.second - m_remoteBufferReadPosition;
}
break;
}
} }
if (find == false) { if (_bufSize == 0) {
// No data in the buffer // No data in the buffer
return 0; return 0;
} }
memcpy(_buf, &m_remoteBuffer[m_remoteBufferReadPosition], _bufSize); {
m_remoteBufferReadPosition += _bufSize; std::unique_lock<std::mutex> lock(m_remote->m_mutex);
memcpy(_buf, &m_remote->m_buffer[m_remote->m_bufferReadPosition], _bufSize);
m_remote->m_bufferReadPosition += _bufSize;
}
m_remote->checkIfWeNeedMoreDataFromNetwork();
return _bufSize; return _bufSize;
} }
int32_t appl::StreamBuffering::sizeReadable() {
std::unique_lock<std::mutex> lock(m_mutex);
for (auto &it : m_bufferFillSection) {
if ( m_bufferReadPosition >= it.first
&& m_bufferReadPosition < it.second) {
return it.second - m_bufferReadPosition;
}
}
// No data in the buffer
return 0;
}
int appl::MediaDecoder::writeFunc(uint8_t* _buf, int _bufSize) { int appl::MediaDecoder::writeFunc(uint8_t* _buf, int _bufSize) {
APPL_ERROR("call write ..."); APPL_ERROR("call write ...");
return _bufSize; return _bufSize;
} }
int64_t appl::MediaDecoder::seekFunc(int64_t _offset, int _whence) { int64_t appl::MediaDecoder::seekFunc(int64_t _offset, int _whence) {
int64_t lastPosition = m_remoteBufferReadPosition; int64_t lastPosition = m_remote->m_bufferReadPosition;
switch (_whence) { switch (_whence) {
case AVSEEK_SIZE: case AVSEEK_SIZE:
APPL_ERROR("call seek 'SIZE' ... " << m_remoteBuffer.size()); APPL_ERROR("call seek 'SIZE' ... " << m_remote->m_buffer.size());
return m_remoteBuffer.size(); return m_remote->m_buffer.size();
case AVSEEK_FORCE: case AVSEEK_FORCE:
APPL_ERROR("call seek 'FORCE' ... pos=" << _offset << " size=" << m_remoteBuffer.size()); APPL_ERROR("call seek 'FORCE' ... pos=" << _offset << " size=" << m_remote->m_buffer.size());
m_remoteBufferReadPosition = _offset; m_remote->m_bufferReadPosition = _offset;
break; break;
case SEEK_SET: case SEEK_SET:
APPL_ERROR("call seek 'SET' ... pos=" << _offset << " size=" << m_remoteBuffer.size()); APPL_ERROR("call seek 'SET' ... pos=" << _offset << " size=" << m_remote->m_buffer.size());
m_remoteBufferReadPosition = _offset; m_remote->m_bufferReadPosition = _offset;
break; break;
case SEEK_CUR: case SEEK_CUR:
APPL_ERROR("call seek 'CUR' ... _offset=" << _offset << " size=" << m_remoteBuffer.size()); APPL_ERROR("call seek 'CUR' ... _offset=" << _offset << " size=" << m_remote->m_buffer.size());
m_remoteBufferReadPosition += _offset; m_remote->m_bufferReadPosition += _offset;
break; break;
case SEEK_END: case SEEK_END:
APPL_ERROR("call seek 'END' ... _end=" << _offset << " size=" << m_remoteBuffer.size()); APPL_ERROR("call seek 'END' ... _end=" << _offset << " size=" << m_remote->m_buffer.size());
m_remoteBufferReadPosition = m_remoteBuffer.size()-_offset; m_remote->m_bufferReadPosition = m_remote->m_buffer.size()-_offset;
break; break;
default: default:
APPL_ERROR("Unknow the _whence=" << _whence); APPL_ERROR("Unknow the _whence=" << _whence);
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
if (m_remoteBufferReadPosition < 0 ) { if (m_remote->m_bufferReadPosition < 0 ) {
APPL_WARNING("Request seek before start of the File"); APPL_WARNING("Request seek before start of the File");
m_remoteBufferReadPosition = 0; m_remote->m_bufferReadPosition = 0;
} }
if (m_remoteBufferReadPosition > m_remoteBuffer.size()) { if (m_remote->m_bufferReadPosition > m_remote->m_buffer.size()) {
APPL_WARNING("Request seek after end of the File"); APPL_WARNING("Request seek after end of the File");
m_remoteBufferReadPosition = m_remoteBuffer.size()-1; m_remote->m_bufferReadPosition = m_remote->m_buffer.size()-1;
} }
if (lastPosition != m_remoteBufferReadPosition) { if (lastPosition != m_remote->m_bufferReadPosition) {
checkIfWeNeedMoreDataFromNetwork(); {
// Force the get of new data ==> this is bad TODO : Update this when possible
std::unique_lock<std::mutex> lock(m_remote->m_mutex);
m_remote->m_callInProgress = false;
}
m_remote->checkIfWeNeedMoreDataFromNetwork();
} }
return m_remoteBufferReadPosition; return m_remote->m_bufferReadPosition;
} }
void appl::MediaDecoder::checkIfWeNeedMoreDataFromNetwork() { bool appl::StreamBuffering::addDataCallback(zeus::Future<zeus::Raw> _fut, int64_t _positionRequest) {
{
std::unique_lock<std::mutex> lock(m_mutex);
bool find = false;
m_callInProgress = false;
if (_fut.hasError() == true) {
APPL_ERROR("Error when loading data (1 MB)");
return true;
}
// TODO : Check buffer size ...
zeus::Raw buffer = _fut.get();
APPL_INFO(" ==> receive DATA : " << _positionRequest << " size=" << buffer.size());
// copy data
memcpy(&m_buffer[_positionRequest], buffer.data(), buffer.size());
// Update the buffer data and positionning
// find if the position correspond at a last positioning:
auto it = m_bufferFillSection.begin();
while (it != m_bufferFillSection.end()) {
if ( _positionRequest >= it->first
&& _positionRequest < it->second) {
if (_positionRequest + buffer.size() > it->second){
it->second = _positionRequest + buffer.size();
}
find = true;
break;
} else if (it->second == _positionRequest) {
it->second += buffer.size();
find = true;
break;
}
auto it2 = it;
++it2;
if ( it2 != m_bufferFillSection.end()
&& _positionRequest + buffer.size() >= it2->first) {
it2->first = _positionRequest;
find = true;
break;
} else {
find = true;
break;
}
++it;
}
if (find == false) {
m_bufferFillSection.insert(it, std::pair<uint32_t,uint32_t>(_positionRequest, _positionRequest + buffer.size()));
}
}
checkIfWeNeedMoreDataFromNetwork();
return true;
}
appl::StreamBuffering::StreamBuffering() {
m_callInProgress = false;
m_mediaId = 0;
m_bufferReadPosition = 0;
}
void appl::StreamBuffering::checkIfWeNeedMoreDataFromNetwork() {
std::unique_lock<std::mutex> lock(m_mutex);
// check if enought data: // check if enought data:
bool find = false; bool find = false;
auto it = m_remoteBufferFillSection.begin(); if (m_callInProgress == true) {
if (it == m_remoteBufferFillSection.end()) { return;
}
int32_t preDownloadBufferSlot = BUFFER_SIZE_GET_SLOT*3;
// When file is < 200Mo ==> just download all...
if (m_buffer.size() < 300*1024*1024) {
preDownloadBufferSlot = m_buffer.size()+10;
}
APPL_INFO("Request DATA ...");
auto it = m_bufferFillSection.begin();
if (it == m_bufferFillSection.end()) {
// no data in the buffer... // no data in the buffer...
//Get some //Get some
// start with loading of 1 Mo // start with loading of 1 Mo
auto futData = m_remoteFileHandle.getPart(0, BUFFER_SIZE_GET_SLOT); APPL_INFO("Request DATA : " << 0 << " size=" << BUFFER_SIZE_GET_SLOT);
auto futData = m_fileHandle.getPart(0, BUFFER_SIZE_GET_SLOT);
auto localShared = ememory::dynamicPointerCast<appl::StreamBuffering>(sharedFromThis());
futData.andThen([=](zeus::Future<zeus::Raw> _fut) mutable { futData.andThen([=](zeus::Future<zeus::Raw> _fut) mutable {
return true; return localShared->addDataCallback(_fut, 0);
}); });
/* m_callInProgress = true;
futData.wait();
if (futData.hasError() == true) {
APPL_ERROR("Error when loading data (First 1 MB)");
}
zeus::Raw buffer = futData.get();
memcpy(&m_remoteBuffer[0], buffer.data(), buffer.size());
m_remoteBufferFillSection.push_back(std::pair<uint32_t,uint32_t>(0,buffer.size()));
return; return;
*/
} }
/* while (it != m_bufferFillSection.end()) {
for (auto &it : m_remoteBufferFillSection) { APPL_INFO("Check : " << it->first << " -> " << it->second << " read-pos=" << m_bufferReadPosition);
if ( m_remoteBufferReadPosition >= it.first if ( m_bufferReadPosition >= it->first
&& m_remoteBufferReadPosition < it.second) { && m_bufferReadPosition < it->second) {
APPL_INFO("Request DATA AAAA ");
find = true; find = true;
// part already download... // part already download... ==> check if we need more data after end position
if (it.second - m_remoteBufferReadPosition < _bufSize) { if (it->second == m_buffer.size()) {
// missing data ==> reduce copy size // need no more data ...
_bufSize = it.second - m_remoteBufferReadPosition; return;
} }
break; if (it->second - m_bufferReadPosition < preDownloadBufferSlot) {
int32_t sizeRequest = BUFFER_SIZE_GET_SLOT;
if (it->second + sizeRequest >= m_buffer.size()) {
sizeRequest = m_buffer.size() - it->second;
}
auto it2 = it;
++it2;
if ( it2 != m_bufferFillSection.end()
&& it->second + sizeRequest >= it2->first) {
sizeRequest = it2->first - it->second;
}
APPL_INFO("Request DATA : " << it->second << " size=" << sizeRequest);
auto futData = m_fileHandle.getPart(it->second, it->second + sizeRequest);
auto localShared = ememory::dynamicPointerCast<appl::StreamBuffering>(sharedFromThis());
futData.andThen([=](zeus::Future<zeus::Raw> _fut) mutable {
return localShared->addDataCallback(_fut, it->second);
});
m_callInProgress = true;
}
// nothing more to do ...
return;
} else if (m_bufferReadPosition < it->first) {
APPL_INFO("Request DATA KKKKK ");
int32_t sizeRequest = BUFFER_SIZE_GET_SLOT;
if (m_bufferReadPosition + sizeRequest >= it->first) {
sizeRequest = it->first - m_bufferReadPosition;
}
APPL_INFO("Request DATA : " << m_bufferReadPosition << " size=" << sizeRequest);
auto futData = m_fileHandle.getPart(m_bufferReadPosition, m_bufferReadPosition+sizeRequest);
auto localShared = ememory::dynamicPointerCast<appl::StreamBuffering>(sharedFromThis());
futData.andThen([=](zeus::Future<zeus::Raw> _fut) mutable {
return localShared->addDataCallback(_fut, m_bufferReadPosition);
});
m_callInProgress = true;
// nothing more to do ...
return;
} }
++it;
} }
APPL_INFO("Request DATA RRRRR ");
APPL_INFO("Request DATA : " << m_bufferReadPosition << " size=" << BUFFER_SIZE_GET_SLOT);
auto futData = m_fileHandle.getPart(m_bufferReadPosition, m_bufferReadPosition + BUFFER_SIZE_GET_SLOT);
auto localShared = ememory::dynamicPointerCast<appl::StreamBuffering>(sharedFromThis());
futData.andThen([=](zeus::Future<zeus::Raw> _fut) mutable {
return localShared->addDataCallback(_fut, 0);
});
m_callInProgress = true;
if (find == false) { if (find == false) {
// No data in the buffer // No data in the buffer
return; return;
} }
*/
} }
void appl::MediaDecoder::init(const std::string& _filename) { void appl::MediaDecoder::init() {
//APPL_ERROR("AAAAAAAAAAAA " << m_isInit << " " << m_remote->sizeReadable());
if ( m_isInit == true
|| m_remote == nullptr
|| m_remote->sizeReadable() < 1024*1024) {// Need to wait at lease 1MB
return;
}
m_updateVideoTimeStampAfterSeek = false; m_updateVideoTimeStampAfterSeek = false;
m_sourceFilename = _filename; //m_sourceFilename = _filename;
ethread::setName("ffmpegThread"); ethread::setName("ffmpegThread");
// open input file, and allocate format context // open input file, and allocate format context
#ifdef APPL_USE_GENERIC_FFMPEG #ifdef APPL_USE_GENERIC_FFMPEG
@ -539,6 +659,7 @@ void appl::MediaDecoder::init(const std::string& _filename) {
// TODO : check this, this will create a memeory leak // TODO : check this, this will create a memeory leak
return; return;
} }
APPL_ERROR("BBBBBB");
m_duration = echrono::Duration(double(m_formatContext->duration)/double(AV_TIME_BASE)); m_duration = echrono::Duration(double(m_formatContext->duration)/double(AV_TIME_BASE));
APPL_INFO("Stream duration : " << m_duration); APPL_INFO("Stream duration : " << m_duration);
// Open Video decoder: // Open Video decoder:
@ -621,6 +742,7 @@ void appl::MediaDecoder::init(const std::string& _filename) {
APPL_ERROR("Could not allocate frame ret=" << ret); APPL_ERROR("Could not allocate frame ret=" << ret);
return; // TODO : An error occured ... !!!!! return; // TODO : An error occured ... !!!!!
} }
APPL_ERROR("ZZZZZZZ");
// initialize packet, set data to nullptr, let the demuxer fill it // initialize packet, set data to nullptr, let the demuxer fill it
av_init_packet(&m_packet); av_init_packet(&m_packet);
m_packet.data = nullptr; m_packet.data = nullptr;
@ -632,12 +754,24 @@ bool appl::MediaDecoder::onThreadCall() {
if (m_stopRequested == true) { if (m_stopRequested == true) {
return true; return true;
} }
init();
if (m_isInit == false) {
// take some time to sleep the decoding ...
std::this_thread::sleep_for(std::chrono::milliseconds(60/100));
return false;
}
if (m_seek >= echrono::Duration(0)) { if (m_seek >= echrono::Duration(0)) {
// seek requested (create a copy to permit to update it in background): // seek requested (create a copy to permit to update it in background):
echrono::Duration tmpSeek = m_seek; echrono::Duration tmpSeek = m_seek;
m_seek = echrono::Duration(-1); m_seek = echrono::Duration(-1);
applySeek(tmpSeek); applySeek(tmpSeek);
} }
// Need to wait at lease 1MB
if (m_remote->sizeReadable() < 1024*1024) {
// take some time to sleep the decoding ...
std::this_thread::sleep_for(std::chrono::milliseconds(60/100));
return false;
}
// check if we have space to decode data // check if we have space to decode data
if ( ( m_videoPool.size() != 0 if ( ( m_videoPool.size() != 0
&& videoGetEmptySlot() == -1) && videoGetEmptySlot() == -1)

View File

@ -55,7 +55,28 @@ namespace appl {
std::vector<audio::channel> m_map; //!< Channel map of the buffer std::vector<audio::channel> m_map; //!< Channel map of the buffer
void configure(audio::format _format, uint32_t _sampleRate, int32_t _nbChannel, int32_t _nbSample); void configure(audio::format _format, uint32_t _sampleRate, int32_t _nbChannel, int32_t _nbSample);
}; };
class StreamBuffering : public ememory::EnableSharedFromThis<StreamBuffering> {
public:
StreamBuffering();
std::mutex m_mutex; //!< local Lock Data protection
ememory::SharedPtr<appl::ClientProperty> m_property; //!< Remote interface that must get data
uint32_t m_mediaId; //!< remote media ID that need to get data
zeus::ProxyFile m_fileHandle; //!< Reference on the remote file
std::vector<uint8_t> m_buffer; //!< preallocated with all needed data
int32_t m_bufferReadPosition; //!< Current position that is read
std::vector<std::pair<uint32_t,uint32_t>> m_bufferFillSection; //!< List of <start-stop> position that contain data
bool m_callInProgress;
public:
bool addDataCallback(zeus::Future<zeus::Raw> _fut, int64_t _positionRequest);
void checkIfWeNeedMoreDataFromNetwork();
uint64_t getSize() {
return m_buffer.size();
}
std::vector<std::pair<uint32_t,uint32_t>> getDownloadPart() {
return m_bufferFillSection;
}
int32_t sizeReadable();
};
class MediaDecoder : public gale::Thread { class MediaDecoder : public gale::Thread {
bool m_stopRequested; bool m_stopRequested;
public: public:
@ -108,7 +129,9 @@ namespace appl {
int decode_packet(int *_gotFrame, int _cached); int decode_packet(int *_gotFrame, int _cached);
int open_codec_context(int *_streamId, AVFormatContext *_formatContext, enum AVMediaType _type); int open_codec_context(int *_streamId, AVFormatContext *_formatContext, enum AVMediaType _type);
double getFps(AVCodecContext *_avctx); double getFps(AVCodecContext *_avctx);
void init(const std::string& _filename); protected:
void init();
public:
void init(ememory::SharedPtr<appl::ClientProperty> _property, uint32_t _mediaId); void init(ememory::SharedPtr<appl::ClientProperty> _property, uint32_t _mediaId);
bool onThreadCall() override; bool onThreadCall() override;
void uninit(); void uninit();
@ -138,13 +161,7 @@ namespace appl {
/* *********************************************** /* ***********************************************
** Section temporary buffer ** Section temporary buffer
***********************************************/ ***********************************************/
protected: ememory::SharedPtr<appl::StreamBuffering> m_remote;
ememory::SharedPtr<appl::ClientProperty> m_remoteProperty; //!< Remote interface that must get data
uint32_t m_remoteMediaId; //!< remote media ID that need to get data
zeus::ProxyFile m_remoteFileHandle; //!< Reference on the remote file
std::vector<uint8_t> m_remoteBuffer; //!< preallocated with all needed data
int32_t m_remoteBufferReadPosition; //!< Current position that is read
std::vector<std::pair<uint32_t,uint32_t>> m_remoteBufferFillSection; //!< List of <start-stop> position that contain data
public: public:
// @brief INTERNAL read callback // @brief INTERNAL read callback
int readFunc(uint8_t* _buf, int _bufSize); int readFunc(uint8_t* _buf, int _bufSize);
@ -152,8 +169,6 @@ namespace appl {
int writeFunc(uint8_t* _buf, int _bufSize); int writeFunc(uint8_t* _buf, int _bufSize);
// @brief INTERNAL seek callback // @brief INTERNAL seek callback
int64_t seekFunc(int64_t _offset, int _whence); int64_t seekFunc(int64_t _offset, int _whence);
protected:
void checkIfWeNeedMoreDataFromNetwork();
}; };
} }

View File

@ -8,6 +8,6 @@
#include <appl/debug.hpp> #include <appl/debug.hpp>
int32_t appl::getLogId() { int32_t appl::getLogId() {
static int32_t g_val = elog::registerInstance("example"); static int32_t g_val = elog::registerInstance("zeus-video-player");
return g_val; return g_val;
} }

View File

@ -100,7 +100,6 @@ void appl::widget::ListViewer::searchElements(std::string _filter) {
appl::widget::ListViewerShared tmpWidget = ememory::staticPointerCast<appl::widget::ListViewer>(sharedFromThis()); appl::widget::ListViewerShared tmpWidget = ememory::staticPointerCast<appl::widget::ListViewer>(sharedFromThis());
remoteServiceVideo.mediaMetadataGetKey(it, "title") remoteServiceVideo.mediaMetadataGetKey(it, "title")
.andThen([=](zeus::Future<std::string> _fut) mutable { .andThen([=](zeus::Future<std::string> _fut) mutable {
std::this_thread::sleep_for(std::chrono::milliseconds(200));
APPL_INFO(" [" << elem->m_id << "] get title: " << _fut.get()); APPL_INFO(" [" << elem->m_id << "] get title: " << _fut.get());
{ {
std::unique_lock<std::mutex> lock(elem->m_mutex); std::unique_lock<std::mutex> lock(elem->m_mutex);
@ -110,61 +109,51 @@ void appl::widget::ListViewer::searchElements(std::string _filter) {
return true; return true;
}); });
remoteServiceVideo.mediaMetadataGetKey(it, "series-name") remoteServiceVideo.mediaMetadataGetKey(it, "series-name")
.andThen([=](zeus::FutureBase _fut) mutable { .andThen([=](zeus::Future<std::string> _fut) mutable {
std::this_thread::sleep_for(std::chrono::milliseconds(200)); APPL_ERROR(" [" << elem->m_id << "] get serie: " << _fut.get());
zeus::Future<std::string> futTmp(_fut);
APPL_ERROR(" [" << elem->m_id << "] get serie: " << futTmp.get());
{ {
std::unique_lock<std::mutex> lock(elem->m_mutex); std::unique_lock<std::mutex> lock(elem->m_mutex);
elem->m_serie = futTmp.get(); elem->m_serie = _fut.get();
} }
tmpWidget->markToRedraw(); tmpWidget->markToRedraw();
return true; return true;
}); });
remoteServiceVideo.mediaMetadataGetKey(it, "saison") remoteServiceVideo.mediaMetadataGetKey(it, "saison")
.andThen([=](zeus::FutureBase _fut) mutable { .andThen([=](zeus::Future<std::string> _fut) mutable {
std::this_thread::sleep_for(std::chrono::milliseconds(200)); APPL_INFO(" [" << elem->m_id << "] get saison: " << _fut.get());
zeus::Future<std::string> futTmp(_fut);
APPL_INFO(" [" << elem->m_id << "] get saison: " << futTmp.get());
{ {
std::unique_lock<std::mutex> lock(elem->m_mutex); std::unique_lock<std::mutex> lock(elem->m_mutex);
elem->m_saison = futTmp.get(); elem->m_saison = _fut.get();
} }
tmpWidget->markToRedraw(); tmpWidget->markToRedraw();
return true; return true;
}); });
remoteServiceVideo.mediaMetadataGetKey(it, "episode") remoteServiceVideo.mediaMetadataGetKey(it, "episode")
.andThen([=](zeus::FutureBase _fut) mutable { .andThen([=](zeus::Future<std::string> _fut) mutable {
std::this_thread::sleep_for(std::chrono::milliseconds(200)); APPL_INFO(" [" << elem->m_id << "] get episode: " << _fut.get());
zeus::Future<std::string> futTmp(_fut);
APPL_INFO(" [" << elem->m_id << "] get episode: " << futTmp.get());
{ {
std::unique_lock<std::mutex> lock(elem->m_mutex); std::unique_lock<std::mutex> lock(elem->m_mutex);
elem->m_episode = futTmp.get(); elem->m_episode = _fut.get();
} }
tmpWidget->markToRedraw(); tmpWidget->markToRedraw();
return true; return true;
}); });
remoteServiceVideo.mediaMetadataGetKey(it, "description") remoteServiceVideo.mediaMetadataGetKey(it, "description")
.andThen([=](zeus::FutureBase _fut) mutable { .andThen([=](zeus::Future<std::string> _fut) mutable {
std::this_thread::sleep_for(std::chrono::milliseconds(200)); APPL_INFO(" [" << elem->m_id << "] get description: " << _fut.get());
zeus::Future<std::string> futTmp(_fut);
APPL_INFO(" [" << elem->m_id << "] get description: " << futTmp.get());
{ {
std::unique_lock<std::mutex> lock(elem->m_mutex); std::unique_lock<std::mutex> lock(elem->m_mutex);
elem->m_description = futTmp.get(); elem->m_description = _fut.get();
} }
tmpWidget->markToRedraw(); tmpWidget->markToRedraw();
return true; return true;
}); });
remoteServiceVideo.mediaMineTypeGet(it) remoteServiceVideo.mediaMineTypeGet(it)
.andThen([=](zeus::FutureBase _fut) mutable { .andThen([=](zeus::Future<std::string> _fut) mutable {
std::this_thread::sleep_for(std::chrono::milliseconds(200)); APPL_INFO(" [" << elem->m_id << "] get mine-type: " << _fut.get());
zeus::Future<std::string> futTmp(_fut);
APPL_INFO(" [" << elem->m_id << "] get mine-type: " << futTmp.get());
{ {
std::unique_lock<std::mutex> lock(elem->m_mutex); std::unique_lock<std::mutex> lock(elem->m_mutex);
elem->m_mineType = futTmp.get(); elem->m_mineType = _fut.get();
if (etk::start_with(elem->m_mineType, "video") == true) { if (etk::start_with(elem->m_mineType, "video") == true) {
// TODO : Optimise this ... // TODO : Optimise this ...
elem->m_thumb = egami::load("DATA:Video.svg", ivec2(128,128)); elem->m_thumb = egami::load("DATA:Video.svg", ivec2(128,128));

View File

@ -74,6 +74,7 @@ void appl::widget::VideoDisplay::loadProgram() {
} }
} }
void appl::widget::VideoDisplay::setFile(const std::string& _filename) { void appl::widget::VideoDisplay::setFile(const std::string& _filename) {
/*
// Stop playing in all case... // Stop playing in all case...
stop(); stop();
// Clear the old interface // Clear the old interface
@ -85,6 +86,7 @@ void appl::widget::VideoDisplay::setFile(const std::string& _filename) {
return; return;
} }
m_decoder->init(_filename); m_decoder->init(_filename);
*/
markToRedraw(); markToRedraw();
} }
@ -262,6 +264,7 @@ void appl::widget::VideoDisplay::periodicEvent(const ewol::event::Time& _event)
} }
} }
// SET AUDIO: // SET AUDIO:
bool getSomething = false;
int32_t idSlot = m_decoder->audioGetOlderSlot(); int32_t idSlot = m_decoder->audioGetOlderSlot();
if ( idSlot != -1 if ( idSlot != -1
&& m_currentTime > m_decoder->m_audioPool[idSlot].m_time) { && m_currentTime > m_decoder->m_audioPool[idSlot].m_time) {
@ -272,6 +275,7 @@ void appl::widget::VideoDisplay::periodicEvent(const ewol::event::Time& _event)
m_audioInterface->write(&m_decoder->m_audioPool[idSlot].m_buffer[0], nbSample); m_audioInterface->write(&m_decoder->m_audioPool[idSlot].m_buffer[0], nbSample);
} }
m_decoder->m_audioPool[idSlot].m_isUsed = false; m_decoder->m_audioPool[idSlot].m_isUsed = false;
getSomething = true;
} }
// SET VIDEO: // SET VIDEO:
idSlot = m_decoder->videoGetOlderSlot(); idSlot = m_decoder->videoGetOlderSlot();
@ -286,6 +290,7 @@ void appl::widget::VideoDisplay::periodicEvent(const ewol::event::Time& _event)
m_decoder->m_videoPool[idSlot].m_isUsed = false; m_decoder->m_videoPool[idSlot].m_isUsed = false;
m_resource->flush(); m_resource->flush();
m_nbFramePushed++; m_nbFramePushed++;
getSomething = true;
} }
// Display FPS ... // Display FPS ...
m_LastResetCounter += _event.getDeltaCallDuration(); m_LastResetCounter += _event.getDeltaCallDuration();
@ -294,7 +299,12 @@ void appl::widget::VideoDisplay::periodicEvent(const ewol::event::Time& _event)
signalFps.emit(m_nbFramePushed); signalFps.emit(m_nbFramePushed);
m_nbFramePushed = 0; m_nbFramePushed = 0;
} }
signalPosition.emit(m_currentTime); if ( getSomething == false
&& m_isPalying == true) {
//m_currentTime -= _event.getDeltaCallDuration();
} else {
signalPosition.emit(m_currentTime);
}
// TODO : Chek if this is needed, the display configuration not change too much ... // TODO : Chek if this is needed, the display configuration not change too much ...
markToRedraw(); markToRedraw();
} }