mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-30 17:01:15 +02:00
gui/movieplayer.cpp: add iso file mount
This commit is contained in:
@@ -46,6 +46,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/timeb.h>
|
#include <sys/timeb.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
|
||||||
#include <video.h>
|
#include <video.h>
|
||||||
#include <libtuxtxt/teletext.h>
|
#include <libtuxtxt/teletext.h>
|
||||||
@@ -68,6 +69,7 @@ extern CRemoteControl *g_RemoteControl; /* neutrino.cpp */
|
|||||||
extern CInfoClock *InfoClock;
|
extern CInfoClock *InfoClock;
|
||||||
|
|
||||||
#define TIMESHIFT_SECONDS 3
|
#define TIMESHIFT_SECONDS 3
|
||||||
|
#define ISO_MOUNT_POINT "/media/iso"
|
||||||
|
|
||||||
CMoviePlayerGui* CMoviePlayerGui::instance_mp = NULL;
|
CMoviePlayerGui* CMoviePlayerGui::instance_mp = NULL;
|
||||||
|
|
||||||
@@ -122,6 +124,7 @@ void CMoviePlayerGui::Init(void)
|
|||||||
tsfilefilter.addFilter("mov");
|
tsfilefilter.addFilter("mov");
|
||||||
tsfilefilter.addFilter("m3u");
|
tsfilefilter.addFilter("m3u");
|
||||||
tsfilefilter.addFilter("pls");
|
tsfilefilter.addFilter("pls");
|
||||||
|
tsfilefilter.addFilter("iso");
|
||||||
|
|
||||||
if (g_settings.network_nfs_moviedir.empty())
|
if (g_settings.network_nfs_moviedir.empty())
|
||||||
Path_local = "/";
|
Path_local = "/";
|
||||||
@@ -146,6 +149,7 @@ void CMoviePlayerGui::Init(void)
|
|||||||
min_y = 0;
|
min_y = 0;
|
||||||
max_y = 0;
|
max_y = 0;
|
||||||
ext_subs = false;
|
ext_subs = false;
|
||||||
|
iso_file = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMoviePlayerGui::cutNeutrino()
|
void CMoviePlayerGui::cutNeutrino()
|
||||||
@@ -346,6 +350,26 @@ void CMoviePlayerGui::Cleanup()
|
|||||||
p_movie_info = NULL;
|
p_movie_info = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMoviePlayerGui::makeFilename()
|
||||||
|
{
|
||||||
|
if(file_name.empty()) {
|
||||||
|
std::string::size_type pos = full_name.find_last_of('/');
|
||||||
|
if(pos != std::string::npos) {
|
||||||
|
file_name = full_name.substr(pos+1);
|
||||||
|
std::replace(file_name.begin(), file_name.end(), '_', ' ');
|
||||||
|
} else
|
||||||
|
file_name = full_name;
|
||||||
|
|
||||||
|
if(file_name.substr(0,14)=="videoplayback?"){//youtube name
|
||||||
|
if(!p_movie_info->epgTitle.empty())
|
||||||
|
file_name = p_movie_info->epgTitle;
|
||||||
|
else
|
||||||
|
file_name = "";
|
||||||
|
}
|
||||||
|
printf("CMoviePlayerGui::makeFilename: full_name [%s] file_name [%s]\n", full_name.c_str(), file_name.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool CMoviePlayerGui::SelectFile()
|
bool CMoviePlayerGui::SelectFile()
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
@@ -414,55 +438,18 @@ bool CMoviePlayerGui::SelectFile()
|
|||||||
is_file_player = true;
|
is_file_player = true;
|
||||||
full_name = file->Name.c_str();
|
full_name = file->Name.c_str();
|
||||||
ret = true;
|
ret = true;
|
||||||
if(file->getType() == CFile::FILE_PLAYLIST) {
|
if(file->getType() == CFile::FILE_PLAYLIST)
|
||||||
std::ifstream infile;
|
parsePlaylist(file);
|
||||||
char cLine[1024];
|
else if(file->getType() == CFile::FILE_ISO)
|
||||||
char name[1024] = { 0 };
|
ret = mountIso(file);
|
||||||
infile.open(file->Name.c_str(), std::ifstream::in);
|
|
||||||
while (infile.good())
|
|
||||||
{
|
|
||||||
infile.getline(cLine, sizeof(cLine));
|
|
||||||
if (cLine[strlen(cLine)-1]=='\r')
|
|
||||||
cLine[strlen(cLine)-1]=0;
|
|
||||||
|
|
||||||
int dur;
|
|
||||||
sscanf(cLine, "#EXTINF:%d,%[^\n]\n", &dur, name);
|
|
||||||
if (strlen(cLine) > 0 && cLine[0]!='#')
|
|
||||||
{
|
|
||||||
char *url = NULL;
|
|
||||||
if ( (url = strstr(cLine, "http://")) || (url = strstr(cLine, "rtmp://")) || (url = strstr(cLine, "rtsp://")) ){
|
|
||||||
if (url != NULL) {
|
|
||||||
printf("name %s [%d] url: %s\n", name, dur, url);
|
|
||||||
full_name = url;
|
|
||||||
if(strlen(name))
|
|
||||||
file_name = name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
menu_ret = filebrowser->getMenuRet();
|
menu_ret = filebrowser->getMenuRet();
|
||||||
CAudioMute::getInstance()->enableMuteIcon(true);
|
CAudioMute::getInstance()->enableMuteIcon(true);
|
||||||
InfoClock->enableInfoClock(true);
|
InfoClock->enableInfoClock(true);
|
||||||
}
|
}
|
||||||
if(ret && file_name.empty()) {
|
if (ret)
|
||||||
std::string::size_type pos = full_name.find_last_of('/');
|
makeFilename();
|
||||||
if(pos != std::string::npos) {
|
|
||||||
file_name = full_name.substr(pos+1);
|
|
||||||
std::replace(file_name.begin(), file_name.end(), '_', ' ');
|
|
||||||
} else
|
|
||||||
file_name = full_name;
|
|
||||||
|
|
||||||
if(file_name.substr(0,14)=="videoplayback?"){//youtube name
|
|
||||||
if(!p_movie_info->epgTitle.empty())
|
|
||||||
file_name = p_movie_info->epgTitle;
|
|
||||||
else
|
|
||||||
file_name = "";
|
|
||||||
}
|
|
||||||
printf("CMoviePlayerGui::SelectFile: full_name [%s] file_name [%s]\n", full_name.c_str(), file_name.c_str());
|
|
||||||
}
|
|
||||||
//store last multiformat play dir
|
//store last multiformat play dir
|
||||||
g_settings.network_nfs_moviedir = Path_local;
|
g_settings.network_nfs_moviedir = Path_local;
|
||||||
|
|
||||||
@@ -845,6 +832,11 @@ void CMoviePlayerGui::PlayFile(void)
|
|||||||
|
|
||||||
playback->SetSpeed(1);
|
playback->SetSpeed(1);
|
||||||
playback->Close();
|
playback->Close();
|
||||||
|
if (iso_file) {
|
||||||
|
iso_file = false;
|
||||||
|
if (umount2(ISO_MOUNT_POINT ,MNT_FORCE))
|
||||||
|
perror(ISO_MOUNT_POINT);
|
||||||
|
}
|
||||||
|
|
||||||
CVFD::getInstance()->ShowIcon(FP_ICON_PLAY, false);
|
CVFD::getInstance()->ShowIcon(FP_ICON_PLAY, false);
|
||||||
CVFD::getInstance()->ShowIcon(FP_ICON_PAUSE, false);
|
CVFD::getInstance()->ShowIcon(FP_ICON_PAUSE, false);
|
||||||
@@ -1622,3 +1614,45 @@ void CMoviePlayerGui::selectAutoLang()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMoviePlayerGui::parsePlaylist(CFile *file)
|
||||||
|
{
|
||||||
|
std::ifstream infile;
|
||||||
|
char cLine[1024];
|
||||||
|
char name[1024] = { 0 };
|
||||||
|
infile.open(file->Name.c_str(), std::ifstream::in);
|
||||||
|
while (infile.good())
|
||||||
|
{
|
||||||
|
infile.getline(cLine, sizeof(cLine));
|
||||||
|
if (cLine[strlen(cLine)-1]=='\r')
|
||||||
|
cLine[strlen(cLine)-1]=0;
|
||||||
|
|
||||||
|
int dur;
|
||||||
|
sscanf(cLine, "#EXTINF:%d,%[^\n]\n", &dur, name);
|
||||||
|
if (strlen(cLine) > 0 && cLine[0]!='#')
|
||||||
|
{
|
||||||
|
char *url = NULL;
|
||||||
|
if ( (url = strstr(cLine, "http://")) || (url = strstr(cLine, "rtmp://")) || (url = strstr(cLine, "rtsp://")) ){
|
||||||
|
if (url != NULL) {
|
||||||
|
printf("name %s [%d] url: %s\n", name, dur, url);
|
||||||
|
full_name = url;
|
||||||
|
if(strlen(name))
|
||||||
|
file_name = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CMoviePlayerGui::mountIso(CFile *file)
|
||||||
|
{
|
||||||
|
printf("ISO file passed: %s\n", file->Name.c_str());
|
||||||
|
safe_mkdir(ISO_MOUNT_POINT);
|
||||||
|
if (my_system(5, "mount", "-o", "loop", file->Name.c_str(), ISO_MOUNT_POINT) == 0) {
|
||||||
|
makeFilename();
|
||||||
|
full_name = "/media/iso";
|
||||||
|
iso_file = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@@ -108,6 +108,7 @@ class CMoviePlayerGui : public CMenuTarget
|
|||||||
|
|
||||||
/* playback from file */
|
/* playback from file */
|
||||||
bool is_file_player;
|
bool is_file_player;
|
||||||
|
bool iso_file;
|
||||||
CFileBrowser * filebrowser;
|
CFileBrowser * filebrowser;
|
||||||
CFileFilter tsfilefilter;
|
CFileFilter tsfilefilter;
|
||||||
std::string Path_local;
|
std::string Path_local;
|
||||||
@@ -142,6 +143,9 @@ class CMoviePlayerGui : public CMenuTarget
|
|||||||
void clearSubtitle();
|
void clearSubtitle();
|
||||||
void selectChapter();
|
void selectChapter();
|
||||||
void selectAutoLang();
|
void selectAutoLang();
|
||||||
|
void parsePlaylist(CFile *file);
|
||||||
|
bool mountIso(CFile *file);
|
||||||
|
void makeFilename();
|
||||||
|
|
||||||
void Cleanup();
|
void Cleanup();
|
||||||
static void *ShowStartHint(void *arg);
|
static void *ShowStartHint(void *arg);
|
||||||
|
Reference in New Issue
Block a user