mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-12 22:09:25 +08:00
media_player: add ability to play images
JPG/PNG sharing in video calls is broken since we use the media player to share all the files Change-Id: Ib85e65405faf46e8b5ff7e4bc7d745af69b1f360
This commit is contained in:

committed by
Adrien Béraud

parent
4660e71bae
commit
cc98f1d0e8
@ -69,6 +69,18 @@ MediaPlayer::configureMediaInputs()
|
||||
devOpts.name = path_;
|
||||
devOpts.loop = "1";
|
||||
|
||||
size_t dot = path_.find_last_of('.');
|
||||
std::string ext = dot == std::string::npos ? "" : path_.substr(dot + 1);
|
||||
bool decodeImg = (ext == "jpeg" || ext == "jpg" || ext == "png" || ext == "pdf");
|
||||
|
||||
// Force 1fps for static image
|
||||
if (decodeImg) {
|
||||
devOpts.format = "image2";
|
||||
devOpts.framerate = 1;
|
||||
} else {
|
||||
JAMI_WARNING("Guessing file type for {}", path_);
|
||||
}
|
||||
|
||||
if (demuxer_->openInput(devOpts) < 0) {
|
||||
emitInfo();
|
||||
return false;
|
||||
@ -112,11 +124,16 @@ MediaPlayer::configureMediaInputs()
|
||||
}
|
||||
});
|
||||
|
||||
fileDuration_ = demuxer_->getDuration();
|
||||
if (fileDuration_ <= 0) {
|
||||
emitInfo();
|
||||
return false;
|
||||
if (decodeImg) {
|
||||
fileDuration_ = 0;
|
||||
} else {
|
||||
fileDuration_ = demuxer_->getDuration();
|
||||
if (fileDuration_ <= 0) {
|
||||
emitInfo();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
emitInfo();
|
||||
demuxer_->updateCurrentState(MediaDemuxer::CurrentState::Demuxing);
|
||||
return true;
|
||||
@ -127,7 +144,7 @@ MediaPlayer::process()
|
||||
{
|
||||
if (!demuxer_)
|
||||
return;
|
||||
if (streamsFinished()) {
|
||||
if (fileDuration_ > 0 && streamsFinished()) {
|
||||
audioStreamEnded_ = false;
|
||||
videoStreamEnded_ = false;
|
||||
playFileFromBeginning();
|
||||
|
BIN
test/unitTest/media/jami.jpg
Normal file
BIN
test/unitTest/media/jami.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.5 KiB |
@ -41,6 +41,7 @@ private:
|
||||
std::string filePath = "./media/test_video_file.mp4";
|
||||
|
||||
void testCreate();
|
||||
void testJPG();
|
||||
void testPause();
|
||||
void testSeekWhilePaused();
|
||||
void testSeekWhilePlaying();
|
||||
@ -49,6 +50,7 @@ private:
|
||||
|
||||
CPPUNIT_TEST_SUITE(MediaPlayerTest);
|
||||
CPPUNIT_TEST(testCreate);
|
||||
CPPUNIT_TEST(testJPG);
|
||||
CPPUNIT_TEST(testPause);
|
||||
CPPUNIT_TEST(testSeekWhilePaused);
|
||||
CPPUNIT_TEST(testSeekWhilePlaying);
|
||||
@ -117,6 +119,23 @@ MediaPlayerTest::testCreate()
|
||||
JAMI_INFO() << "End testCreate";
|
||||
}
|
||||
|
||||
void
|
||||
MediaPlayerTest::testJPG()
|
||||
{
|
||||
JAMI_INFO() << "Start testJpg";
|
||||
std::string filePathJpg = "./media/jami.jpg";
|
||||
auto pid = jami::createMediaPlayer(filePathJpg);
|
||||
|
||||
CPPUNIT_ASSERT(pid == playerId2_);
|
||||
CPPUNIT_ASSERT(mediaPlayer->getId() == pid);
|
||||
CPPUNIT_ASSERT(mediaPlayer->isInputValid());
|
||||
CPPUNIT_ASSERT(audio_stream_ != -1);
|
||||
CPPUNIT_ASSERT(video_stream_ != -1);
|
||||
CPPUNIT_ASSERT(mediaPlayer->isPaused());
|
||||
CPPUNIT_ASSERT(mediaPlayer->getPlayerPosition() == 0);
|
||||
JAMI_INFO() << "End testJpg";
|
||||
}
|
||||
|
||||
void
|
||||
MediaPlayerTest::testPause()
|
||||
{
|
||||
|
Reference in New Issue
Block a user