Initial import from SVN
This commit is contained in:
@@ -0,0 +1,139 @@
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <Wt/WText>
|
||||
#include <Wt/WPushButton>
|
||||
|
||||
#include <Wt/WMediaPlayer>
|
||||
#include <Wt/WFileResource>
|
||||
#include "transcode/Parameters.hpp"
|
||||
|
||||
#include "resource/AvConvTranscodeStreamResource.hpp"
|
||||
|
||||
#include "VideoDatabaseWidget.hpp"
|
||||
|
||||
|
||||
VideoDatabaseWidget::VideoDatabaseWidget( Wt::WContainerWidget *parent)
|
||||
: Wt::WContainerWidget(parent),
|
||||
_db("test.db") // TODO
|
||||
{
|
||||
_table = new Wt::WTable( this );
|
||||
_table->setHeaderCount(1);
|
||||
|
||||
Wt::Dbo::Transaction transaction ( _db.getSession() );
|
||||
|
||||
updateView( Path::pointer() );
|
||||
|
||||
_table->addStyleClass("table form-inline");
|
||||
|
||||
_table->toggleStyleClass("table-hover", true);
|
||||
_table->toggleStyleClass("table-striped", true);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
VideoDatabaseWidget::addHeader(void)
|
||||
{
|
||||
_table->elementAt(0, 0)->addWidget(new Wt::WText("Name"));
|
||||
_table->elementAt(0, 1)->addWidget(new Wt::WText("Duration"));
|
||||
_table->elementAt(0, 2)->addWidget(new Wt::WText("Action"));
|
||||
}
|
||||
|
||||
void
|
||||
VideoDatabaseWidget::addDirectory(const std::string& name, const boost::filesystem::path& path)
|
||||
{
|
||||
|
||||
int row = _table->rowCount();
|
||||
|
||||
std::cout << "Adding DIR at row " << row << ", path = '" << path << "'" << std::endl;
|
||||
|
||||
new Wt::WText(Wt::WString::fromUTF8( name ), _table->elementAt(row, 0));
|
||||
new Wt::WText(Wt::WString::fromUTF8( " " ), _table->elementAt(row, 1));
|
||||
|
||||
Wt::WPushButton* btn = new Wt::WPushButton(Wt::WString::fromUTF8( "Open"), _table->elementAt(row, 2));
|
||||
btn->clicked().connect( boost::bind(&VideoDatabaseWidget::handleOpenDirectory, this, path) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
VideoDatabaseWidget::addVideo(const std::string& name, const boost::posix_time::time_duration& duration, const boost::filesystem::path& path)
|
||||
{
|
||||
|
||||
int row = _table->rowCount();
|
||||
|
||||
std::cout << "Adding VIDEO at row " << row << ", path = '" << path << "'" << std::endl;
|
||||
|
||||
new Wt::WText(Wt::WString::fromUTF8( name ), _table->elementAt(row, 0));
|
||||
new Wt::WText(Wt::WString::fromUTF8( boost::posix_time::to_simple_string( duration )), _table->elementAt(row, 1));
|
||||
|
||||
Wt::WPushButton* btn = new Wt::WPushButton(Wt::WString::fromUTF8( "Play"), _table->elementAt(row, 2));
|
||||
btn->clicked().connect( boost::bind(&VideoDatabaseWidget::handlePlayVideo, this, path) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
VideoDatabaseWidget::updateView(Path::pointer directory)
|
||||
{
|
||||
// Clear table from row 1 to end
|
||||
// while(_table->rowCount() > 2)
|
||||
// _table->deleteRow( _table->rowCount() - 1);
|
||||
|
||||
_table->clear();
|
||||
|
||||
addHeader();
|
||||
|
||||
std::vector< Path::pointer > pathes;
|
||||
if(directory)
|
||||
{
|
||||
pathes = directory->getChilds();
|
||||
// Add parent directory
|
||||
addDirectory("<Parent>", directory->getParent() ? directory->getParent() ->getPath() : boost::filesystem::path());
|
||||
}
|
||||
else
|
||||
pathes = Path::getRoots(_db.getSession() );
|
||||
|
||||
// Add childs
|
||||
BOOST_FOREACH(Path::pointer path, pathes)
|
||||
{
|
||||
std::cout << "Adding path " << path->getPath() << std::endl;
|
||||
if (path->isDirectory())
|
||||
addDirectory( path->getFileName(), path->getPath());
|
||||
else if (path->getVideo())
|
||||
addVideo( path->getFileName(), path->getVideo()->getDuration(), path->getPath());
|
||||
else
|
||||
std::cerr << "Bad type??" << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
VideoDatabaseWidget::handleOpenDirectory(boost::filesystem::path path)
|
||||
{
|
||||
Wt::Dbo::Transaction transaction ( _db.getSession() );
|
||||
|
||||
Path::pointer directory = Path::getByPath(_db.getSession(), path);
|
||||
updateView(directory);
|
||||
}
|
||||
|
||||
void
|
||||
VideoDatabaseWidget::handlePlayVideo(const boost::filesystem::path& videoFilePath)
|
||||
{
|
||||
std::cout << "Wants to play video " << videoFilePath << std::endl;
|
||||
|
||||
Wt::Dbo::Transaction transaction ( _db.getSession() );
|
||||
|
||||
Path::pointer path = Path::getByPath(_db.getSession(), videoFilePath);
|
||||
Video::pointer video;
|
||||
if (path)
|
||||
video = path->getVideo();
|
||||
|
||||
if (!video)
|
||||
{
|
||||
std::cerr << "Cannot find video for this path '" << videoFilePath << "'" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
// Emit signal
|
||||
playVideo().emit(videoFilePath);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef VIDEO_DB_WIDGET_HPP
|
||||
#define VIDEO_DB_WIDGET_HPP
|
||||
|
||||
#include <Wt/WTable>
|
||||
#include <Wt/WContainerWidget>
|
||||
|
||||
#include "database/DatabaseHandler.hpp"
|
||||
#include "database/FileTypes.hpp"
|
||||
|
||||
class VideoDatabaseWidget : public Wt::WContainerWidget
|
||||
{
|
||||
public:
|
||||
VideoDatabaseWidget( Wt::WContainerWidget *parent = 0);
|
||||
|
||||
// Signals
|
||||
Wt::Signal< boost::filesystem::path >& playVideo() { return _playVideo; }
|
||||
|
||||
private:
|
||||
|
||||
|
||||
void updateView(Path::pointer directory);
|
||||
void handleOpenDirectory(boost::filesystem::path directory);
|
||||
void handlePlayVideo(const boost::filesystem::path& path);
|
||||
|
||||
void addHeader(void);
|
||||
void addDirectory(const std::string& name, const boost::filesystem::path& path);
|
||||
void addVideo(const std::string& name, const boost::posix_time::time_duration& duration, const boost::filesystem::path& path);
|
||||
|
||||
Wt::Signal< boost::filesystem::path > _playVideo;
|
||||
|
||||
DatabaseHandler _db;
|
||||
|
||||
Wt::WTable* _table;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <Wt/WMediaPlayer>
|
||||
|
||||
#include "VideoParametersDialog.hpp"
|
||||
|
||||
#include "VideoMediaPlayerWidget.hpp"
|
||||
|
||||
|
||||
Wt::WMediaPlayer::Encoding
|
||||
convert(Transcode::Format format)
|
||||
{
|
||||
switch( format.getEncoding() )
|
||||
{
|
||||
case Transcode::Format::OGA: return Wt::WMediaPlayer::OGA;
|
||||
case Transcode::Format::OGV: return Wt::WMediaPlayer::OGV;
|
||||
case Transcode::Format::MP3: return Wt::WMediaPlayer::MP3;
|
||||
case Transcode::Format::WEBMA: return Wt::WMediaPlayer::WEBMA;
|
||||
case Transcode::Format::WEBMV: return Wt::WMediaPlayer::WEBMV;
|
||||
case Transcode::Format::FLV: return Wt::WMediaPlayer::FLV;
|
||||
case Transcode::Format::M4A: return Wt::WMediaPlayer::M4A;
|
||||
case Transcode::Format::M4V: return Wt::WMediaPlayer::M4V;
|
||||
}
|
||||
assert(0);
|
||||
}
|
||||
|
||||
|
||||
VideoMediaPlayerWidget::VideoMediaPlayerWidget( const Transcode::Parameters& parameters, Wt::WContainerWidget *parent)
|
||||
: Wt::WContainerWidget(parent),
|
||||
_mediaResource(nullptr),
|
||||
_currentParameters(parameters),
|
||||
_dialog(nullptr)
|
||||
{
|
||||
_mediaPlayer = new Wt::WMediaPlayer( Wt::WMediaPlayer::Video, this );
|
||||
// _mediaPlayer->setAlternativeContent (new Wt::WText("You don't have HTML5 audio support!"));
|
||||
// _mediaPlayer->setOptions( Wt::WMediaPlayer::Autoplay );
|
||||
// _mediaPlayer->addSource( Wt::WMediaPlayer::WEBMV, "" );
|
||||
|
||||
{
|
||||
Wt::WContainerWidget *container = new Wt::WContainerWidget(this);
|
||||
|
||||
_playBtn = new Wt::WPushButton("Play", container );
|
||||
_pauseBtn = new Wt::WPushButton("Pause", container );
|
||||
|
||||
_curTime = new Wt::WText(container);
|
||||
_timeSlider = new Wt::WSlider( container );
|
||||
_duration = new Wt::WText(container);
|
||||
|
||||
_volumeSlider = new Wt::WSlider( container );
|
||||
_volumeSlider->setRange(0,100);
|
||||
_volumeSlider->setValue(_mediaPlayer->volume() * 100);
|
||||
|
||||
_mediaPlayer->setControlsWidget( container );
|
||||
_mediaPlayer->setButton(Wt::WMediaPlayer::Play, _playBtn);
|
||||
_mediaPlayer->setButton(Wt::WMediaPlayer::Pause, _pauseBtn);
|
||||
|
||||
_mediaPlayer->setText( Wt::WMediaPlayer::CurrentTime, _curTime);
|
||||
_mediaPlayer->setText( Wt::WMediaPlayer::Duration, _duration);
|
||||
|
||||
_mediaPlayer->timeUpdated().connect(this, &VideoMediaPlayerWidget::handleTimeUpdated);
|
||||
|
||||
Wt::WPushButton* fullScreenButton = new Wt::WPushButton("Fullscreen", container);
|
||||
_mediaPlayer->setButton(Wt::WMediaPlayer::FullScreen, fullScreenButton);
|
||||
|
||||
Wt::WPushButton* restoreScreenButton = new Wt::WPushButton("Restore screen", container);
|
||||
_mediaPlayer->setButton(Wt::WMediaPlayer::RestoreScreen, restoreScreenButton);
|
||||
|
||||
_mediaPlayer->timeUpdated().connect(this, &VideoMediaPlayerWidget::handleTimeUpdated);
|
||||
|
||||
_timeSlider->valueChanged().connect(this, &VideoMediaPlayerWidget::handlePlayOffset);
|
||||
_timeSlider->sliderMoved().connect(this, &VideoMediaPlayerWidget::handleSliderMoved);
|
||||
|
||||
_volumeSlider->sliderMoved().connect(this, &VideoMediaPlayerWidget::handleVolumeSliderMoved);
|
||||
}
|
||||
|
||||
|
||||
Wt::WPushButton* closeButton = new Wt::WPushButton("Close", this);
|
||||
closeButton->clicked().connect( this, &VideoMediaPlayerWidget::handleClose );
|
||||
|
||||
Wt::WPushButton* parametersButton = new Wt::WPushButton("Parameters", this);
|
||||
parametersButton->clicked().connect( this, &VideoMediaPlayerWidget::handleParametersEdit );
|
||||
|
||||
load(parameters);
|
||||
}
|
||||
|
||||
void
|
||||
VideoMediaPlayerWidget::load(const Transcode::Parameters& parameters)
|
||||
{
|
||||
_mediaPlayer->clearSources();
|
||||
|
||||
_currentParameters = parameters;
|
||||
|
||||
_mediaInternalLink.setResource( nullptr );
|
||||
if (_mediaResource)
|
||||
delete _mediaResource;
|
||||
|
||||
_mediaResource = new AvConvTranscodeStreamResource( parameters, this );
|
||||
_mediaInternalLink.setResource( _mediaResource );
|
||||
|
||||
_mediaPlayer->addSource( convert(parameters.getOutputFormat()), _mediaInternalLink );
|
||||
|
||||
_timeSlider->setRange(0, parameters.getInputMediaFile().getDuration().total_seconds() );
|
||||
_timeSlider->setValue( parameters.getOffset().total_seconds() );
|
||||
|
||||
_duration->setText( boost::posix_time::to_simple_string( parameters.getInputMediaFile().getDuration() ));
|
||||
|
||||
_mediaPlayer->play();
|
||||
}
|
||||
|
||||
void
|
||||
VideoMediaPlayerWidget::handlePlayOffset(int offsetSecs)
|
||||
{
|
||||
std::cout << "Want to play at offset " << offsetSecs << std::endl;;
|
||||
_currentParameters.setOffset( boost::posix_time::seconds(offsetSecs) );
|
||||
load( _currentParameters );
|
||||
|
||||
_timeSlider->setValue( offsetSecs );
|
||||
}
|
||||
|
||||
void
|
||||
VideoMediaPlayerWidget::handleSliderMoved(int value)
|
||||
{
|
||||
std::cout << "Slider moved to " << value << std::endl;
|
||||
_curTime->setText( boost::posix_time::to_simple_string( boost::posix_time::seconds( value ) ) );
|
||||
}
|
||||
|
||||
void
|
||||
VideoMediaPlayerWidget::handleTimeUpdated(void)
|
||||
{
|
||||
std::cout << "Time updated to " << _mediaPlayer->currentTime() << std::endl;
|
||||
|
||||
if (_mediaPlayer->currentTime() > 0 && _mediaPlayer->currentTime() < _currentParameters.getInputMediaFile().getDuration().total_seconds())
|
||||
{
|
||||
boost::posix_time::time_duration currentTime ( boost::posix_time::seconds( _mediaPlayer->currentTime() + _currentParameters.getOffset().total_seconds()));
|
||||
|
||||
_timeSlider->setValue( currentTime.total_seconds() );
|
||||
_curTime->setText( boost::posix_time::to_simple_string( currentTime) );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
VideoMediaPlayerWidget::handleVolumeSliderMoved(int value)
|
||||
{
|
||||
_mediaPlayer->setVolume( value / 100. );
|
||||
}
|
||||
|
||||
void
|
||||
VideoMediaPlayerWidget::handleClose(void)
|
||||
{
|
||||
_close.emit();
|
||||
}
|
||||
|
||||
void
|
||||
VideoMediaPlayerWidget::handleParametersEdit(void)
|
||||
{
|
||||
|
||||
_dialog = new VideoParametersDialog("Parameters");
|
||||
_dialog->load(_currentParameters);
|
||||
|
||||
_dialog->show();
|
||||
|
||||
_dialog->finished().connect(this, &VideoMediaPlayerWidget::handleParametersDone);
|
||||
}
|
||||
|
||||
void
|
||||
VideoMediaPlayerWidget::handleParametersDone(Wt::WDialog::DialogCode code)
|
||||
{
|
||||
assert(_dialog != nullptr);
|
||||
|
||||
if (code == Wt::WDialog::Accepted)
|
||||
{
|
||||
_dialog->save( _currentParameters );
|
||||
|
||||
// TODO SYNC current offset with player?
|
||||
// HACK use slider current value
|
||||
handlePlayOffset( _timeSlider->value());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
#ifndef __VIDEO_MEDIA_PLAYER_WIDGET_HPP
|
||||
#define __VIDEO_MEDIA_PLAYER_WIDGET_HPP
|
||||
|
||||
#include <Wt/WDialog>
|
||||
#include <Wt/WSlider>
|
||||
#include <Wt/WPushButton>
|
||||
#include <Wt/WContainerWidget>
|
||||
#include <Wt/WLink>
|
||||
|
||||
#include "VideoParametersDialog.hpp"
|
||||
|
||||
#include "transcode/Parameters.hpp"
|
||||
#include "resource/AvConvTranscodeStreamResource.hpp"
|
||||
|
||||
class VideoMediaPlayerWidget : public Wt::WContainerWidget
|
||||
{
|
||||
public:
|
||||
|
||||
VideoMediaPlayerWidget( const Transcode::Parameters& parameters, Wt::WContainerWidget *parent = 0);
|
||||
|
||||
|
||||
Wt::Signal<void>& close() { return _close; };
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Signals
|
||||
Wt::Signal<void> _close;
|
||||
|
||||
void load(const Transcode::Parameters& parameters);
|
||||
|
||||
// Player controls
|
||||
void handlePlayOffset(int offsetSecs);
|
||||
void handleTimeUpdated(void);
|
||||
void handleSliderMoved(int value);
|
||||
void handleFullscreen(void);
|
||||
void handleVolumeSliderMoved(int value);
|
||||
|
||||
void handleClose(void);
|
||||
|
||||
void handleParametersEdit(void);
|
||||
void handleParametersDone(Wt::WDialog::DialogCode);
|
||||
|
||||
// Core
|
||||
Wt::WMediaPlayer* _mediaPlayer;
|
||||
AvConvTranscodeStreamResource* _mediaResource;
|
||||
Wt::WLink _mediaInternalLink;
|
||||
|
||||
// Controls
|
||||
Transcode::Parameters _currentParameters;
|
||||
Wt::WPushButton* _playBtn;
|
||||
Wt::WPushButton* _pauseBtn;
|
||||
Wt::WSlider* _timeSlider;
|
||||
Wt::WSlider* _volumeSlider;
|
||||
Wt::WText* _curTime;
|
||||
Wt::WText* _duration;
|
||||
|
||||
VideoParametersDialog* _dialog;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <Wt/WPushButton>
|
||||
#include <Wt/WLabel>
|
||||
#include <Wt/WTable>
|
||||
|
||||
#include "VideoParametersDialog.hpp"
|
||||
|
||||
using namespace Transcode;
|
||||
|
||||
static const std::list<Stream::Type> streamTypes = {Stream::Video, Stream::Audio, Stream::Subtitle};
|
||||
|
||||
VideoParametersDialog::VideoParametersDialog(const Wt::WString &windowTitle, Wt::WDialog* parent)
|
||||
: Wt::WDialog(windowTitle, parent)
|
||||
{
|
||||
|
||||
Wt::WTable* layout = new Wt::WTable(contents());
|
||||
int row = 0;
|
||||
|
||||
{
|
||||
Wt::WLabel* label = new Wt::WLabel("Format");
|
||||
_outputFormat = new Wt::WComboBox();
|
||||
label->setBuddy(_outputFormat);
|
||||
|
||||
layout->elementAt(row, 0)->addWidget(label);
|
||||
layout->elementAt(row, 1)->addWidget(_outputFormat);
|
||||
|
||||
_outputFormatModel = new Wt::WStringListModel(_outputFormat);
|
||||
|
||||
std::vector<Format> formats = Format::get( Format::Video );
|
||||
|
||||
for(std::size_t idFormat = 0; idFormat < formats.size(); ++idFormat)
|
||||
{
|
||||
_outputFormatModel->addString(formats[idFormat].getDesc());
|
||||
_outputFormatModel->setData(idFormat, 0, formats[idFormat].getEncoding(), Wt::UserRole);
|
||||
}
|
||||
|
||||
_outputFormat->setModel(_outputFormatModel);
|
||||
|
||||
row++;
|
||||
}
|
||||
|
||||
createStreamWidgets("Video", Stream::Video, layout);
|
||||
createStreamWidgets("Audio", Stream::Audio, layout);
|
||||
createStreamWidgets("Subtitles", Stream::Subtitle, layout);
|
||||
|
||||
Wt::WPushButton *ok = new Wt::WPushButton("Apply", contents());
|
||||
ok->clicked().connect(this, &Wt::WDialog::accept);
|
||||
|
||||
Wt::WPushButton *cancel = new Wt::WPushButton("Cancel", contents());
|
||||
cancel->clicked().connect(this, &Wt::WDialog::reject);
|
||||
}
|
||||
|
||||
void
|
||||
VideoParametersDialog::createStreamWidgets(const Wt::WString& labelString, Transcode::Stream::Type type, Wt::WTable* layout)
|
||||
{
|
||||
int row = layout->rowCount();
|
||||
|
||||
Wt::WLabel* label = new Wt::WLabel(labelString);
|
||||
Wt::WComboBox *combo = new Wt::WComboBox();
|
||||
label->setBuddy(combo);
|
||||
|
||||
layout->elementAt(row, 0)->addWidget(label);
|
||||
layout->elementAt(row, 1)->addWidget(combo);
|
||||
|
||||
Wt::WStringListModel* model = new Wt::WStringListModel(combo);
|
||||
|
||||
combo->setModel(model);
|
||||
|
||||
_streamSelection.insert( std::make_pair(type, std::make_pair(combo, model) ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
VideoParametersDialog::handleApply()
|
||||
{
|
||||
_apply.emit();
|
||||
}
|
||||
|
||||
void
|
||||
VideoParametersDialog::addStreams(Wt::WStringListModel* model, const std::vector<Stream>& streams)
|
||||
{
|
||||
for (std::size_t idStream = 0; idStream < streams.size(); ++idStream)
|
||||
{
|
||||
const Stream& stream = streams[idStream];
|
||||
|
||||
std::ostringstream oss;
|
||||
if (!stream.getLanguage().empty())
|
||||
oss << "[" << stream.getLanguage() << "] ";
|
||||
|
||||
oss << stream.getDesc();
|
||||
|
||||
model->addString(oss.str());
|
||||
model->setData(idStream, 0, stream.getId(), Wt::UserRole);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
VideoParametersDialog::selectStream(const Wt::WStringListModel* model, Stream::Id streamId, Wt::WComboBox* combo)
|
||||
{
|
||||
for (int idStream = 0; idStream < model->rowCount(); ++idStream)
|
||||
{
|
||||
Stream::Id id = boost::any_cast<Stream::Id>( model->data( model->index(idStream, 0), Wt::UserRole));
|
||||
if (id == streamId)
|
||||
{
|
||||
combo->setCurrentIndex(idStream);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
VideoParametersDialog::load(const Transcode::Parameters& parameters)
|
||||
{
|
||||
// Select proper encoding
|
||||
for (int row = 0; row < _outputFormat->count(); ++row)
|
||||
{
|
||||
Format::Encoding encoding = boost::any_cast<Format::Encoding>( _outputFormatModel->data(_outputFormatModel->index(row,0), Wt::UserRole));
|
||||
if (encoding == parameters.getOutputFormat().getEncoding()) {
|
||||
_outputFormat->setCurrentIndex(row);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the current selected input streams
|
||||
Parameters::StreamMap streamMap = parameters.getInputStreams();;
|
||||
|
||||
// Populate the combox with the available streams
|
||||
// And then show the selected one
|
||||
BOOST_FOREACH(Stream::Type streamType, streamTypes)
|
||||
{
|
||||
Wt::WComboBox* combo = _streamSelection[streamType].first;
|
||||
Wt::WStringListModel* model = _streamSelection[streamType].second;
|
||||
|
||||
addStreams(model, parameters.getInputMediaFile().getStreams( streamType ) );
|
||||
|
||||
selectStream(model, streamMap[streamType], combo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
VideoParametersDialog::save(Transcode::Parameters& parameters)
|
||||
{
|
||||
std::cout << "Grabbing user input!" << std::endl;
|
||||
|
||||
// Get encoder used
|
||||
Format::Encoding encoding = boost::any_cast<Format::Encoding>( _outputFormatModel->data(_outputFormatModel->index(_outputFormat->currentIndex(), 0), Wt::UserRole));
|
||||
parameters.setOutputFormat( Format::get(encoding) );
|
||||
|
||||
// Get stream selected, if any
|
||||
BOOST_FOREACH(Stream::Type streamType, streamTypes)
|
||||
{
|
||||
Wt::WComboBox* combo = _streamSelection[streamType].first;
|
||||
Wt::WStringListModel* model = _streamSelection[streamType].second;
|
||||
|
||||
if (combo->currentIndex() >= 0)
|
||||
{
|
||||
Stream::Id streamId = boost::any_cast<Stream::Id>( model->data(model->index(combo->currentIndex(), 0), Wt::UserRole));
|
||||
|
||||
parameters.selectInputStream(streamType, streamId);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
#ifndef VIDEO_PARAMETER_DIALOG
|
||||
#define VIDEO_PARAMETER_DIALOG
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <Wt/WSignal>
|
||||
#include <Wt/WDialog>
|
||||
#include <Wt/WComboBox>
|
||||
#include <Wt/WStringListModel>
|
||||
#include <Wt/WString>
|
||||
|
||||
#include "transcode/Parameters.hpp"
|
||||
|
||||
class VideoParametersDialog : public Wt::WDialog
|
||||
{
|
||||
public:
|
||||
// parameters to be edited
|
||||
VideoParametersDialog(const Wt::WString &windowTitle, Wt::WDialog* parent = 0);
|
||||
|
||||
// Populates widget contents using these paramaters
|
||||
void load(const Transcode::Parameters& parameters);
|
||||
|
||||
// Save widgets contents into these parameters
|
||||
void save(Transcode::Parameters& parameters);
|
||||
|
||||
// Signal to be emitted if parameters are changed
|
||||
Wt::Signal<void>& apply() { return _apply; }
|
||||
|
||||
private:
|
||||
|
||||
void handleApply(void);
|
||||
|
||||
// Stream handling
|
||||
void createStreamWidgets(const Wt::WString& label, Transcode::Stream::Type type, Wt::WTable* layout);
|
||||
void addStreams(Wt::WStringListModel* model, const std::vector<Transcode::Stream>& streams);
|
||||
void selectStream(const Wt::WStringListModel* model, Transcode::Stream::Id streamId, Wt::WComboBox* combo);
|
||||
|
||||
Wt::Signal<void> _apply;
|
||||
|
||||
Wt::WComboBox* _outputFormat;
|
||||
Wt::WStringListModel* _outputFormatModel;
|
||||
|
||||
std::map<Transcode::Stream::Type, std::pair<Wt::WComboBox*, Wt::WStringListModel* > > _streamSelection;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
#include <Wt/WApplication>
|
||||
#include <Wt/WEnvironment>
|
||||
|
||||
#include "VideoWidget.hpp"
|
||||
|
||||
|
||||
VideoWidget::VideoWidget(Wt::WContainerWidget* parent )
|
||||
: Wt::WContainerWidget(parent)
|
||||
{
|
||||
|
||||
_videoDbWidget = new VideoDatabaseWidget(this);
|
||||
|
||||
_videoDbWidget->playVideo().connect(this, &VideoWidget::playVideo);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
VideoWidget::search(const std::string& searchText)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
void
|
||||
VideoWidget::backToList(void)
|
||||
{
|
||||
if (_mediaPlayer)
|
||||
delete _mediaPlayer;
|
||||
|
||||
_videoDbWidget->setHidden(false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
VideoWidget::playVideo(boost::filesystem::path p)
|
||||
{
|
||||
std::cout << "Want to play video " << p << "'" << std::endl;
|
||||
try {
|
||||
|
||||
// TODO get user's encoding preference
|
||||
Transcode::InputMediaFile inputFile(p);
|
||||
|
||||
Transcode::Format::Encoding encoding;
|
||||
|
||||
if (Wt::WApplication::instance()->environment().agentIsChrome())
|
||||
encoding = Transcode::Format::WEBMV;
|
||||
else
|
||||
encoding = Transcode::Format::FLV;
|
||||
|
||||
Transcode::Parameters parameters(inputFile, Transcode::Format::get(encoding), 128000, 500000);
|
||||
|
||||
_mediaPlayer = new VideoMediaPlayerWidget(parameters, this);
|
||||
_mediaPlayer->close().connect(this, &VideoWidget::backToList);
|
||||
|
||||
_videoDbWidget->setHidden(true);
|
||||
}
|
||||
catch( std::exception& e) {
|
||||
std::cerr <<"Caught exception while loading '" << p << "': " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef VIDEO_WIDGET_HPP
|
||||
#define VIDEO_WIDGET_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <Wt/WContainerWidget>
|
||||
|
||||
#include "video/VideoMediaPlayerWidget.hpp"
|
||||
#include "video/VideoDatabaseWidget.hpp"
|
||||
|
||||
class VideoWidget : public Wt::WContainerWidget
|
||||
{
|
||||
public:
|
||||
|
||||
VideoWidget(Wt::WContainerWidget* parent = 0);
|
||||
|
||||
void search(const std::string& searchText);
|
||||
|
||||
private:
|
||||
|
||||
void backToList(void);
|
||||
void playVideo(boost::filesystem::path p);
|
||||
|
||||
VideoDatabaseWidget* _videoDbWidget;
|
||||
VideoMediaPlayerWidget* _mediaPlayer;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user