Skip to content

Commit

Permalink
Refactor to Mlt::Controller::isImageProducer().
Browse files Browse the repository at this point in the history
  • Loading branch information
ddennedy committed Jan 27, 2015
1 parent 23b2429 commit 6c49a67
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
6 changes: 2 additions & 4 deletions src/docks/playlistdock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,7 @@ void PlaylistDock::on_actionOpen_triggered()
if (i) {
QString xml = MLT.XML(i->producer);
Mlt::Producer* p = new Mlt::Producer(MLT.profile(), "xml-string", xml.toUtf8().constData());
QString service = p->get("mlt_service");
if (service == "pixbuf" || service == "qimage")
if (MLT.isImageProducer(p))
p->set_in_and_out(i->frame_in, i->frame_out);
emit clipOpened(p, i->frame_in, i->frame_out);
delete i;
Expand Down Expand Up @@ -314,8 +313,7 @@ void PlaylistDock::on_tableView_doubleClicked(const QModelIndex &index)
} else {
QString xml = MLT.XML(i->producer);
Mlt::Producer* p = new Mlt::Producer(MLT.profile(), "xml-string", xml.toUtf8().constData());
QString service = p->get("mlt_service");
if (service == "pixbuf" || service == "qimage")
if (MLT.isImageProducer(p))
p->set_in_and_out(i->frame_in, i->frame_out);
emit clipOpened(p, i->frame_in, i->frame_out);
}
Expand Down
3 changes: 1 addition & 2 deletions src/docks/timelinedock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,7 @@ void TimelineDock::openClip(int trackIndex, int clipIndex)
if (info) {
QString xml = MLT.XML(info->producer);
Mlt::Producer* p = new Mlt::Producer(MLT.profile(), "xml-string", xml.toUtf8().constData());
QString service = p->get("mlt_service");
if (service == "pixbuf" || service == "qimage")
if (MLT.isImageProducer(p))
p->set_in_and_out(info->frame_in, info->frame_out);
emit clipOpened(p, info->frame_in, info->frame_out);
}
Expand Down
5 changes: 2 additions & 3 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1728,7 +1728,7 @@ QWidget *MainWindow::loadProducerWidget(Mlt::Producer* producer)
w = new X11grabWidget(this);
else if (service.startsWith("avformat"))
w = new AvformatProducerWidget(this);
else if (service == "pixbuf" || service == "qimage") {
else if (MLT.isImageProducer(producer)) {
ImageProducerWidget* ipw = new ImageProducerWidget(this);
connect(m_player, SIGNAL(outChanged(int)), ipw, SLOT(setOutPoint(int)));
w = ipw;
Expand Down Expand Up @@ -1960,8 +1960,7 @@ class AppendTask : public QRunnable
foreach (QString filename, filenames) {
Mlt::Producer p(MLT.profile(), filename.toUtf8().constData());
if (p.is_valid()) {
QString service(p.get("mlt_service"));
if (service == "pixbuf" || service == "qimage") {
if (MLT.isImageProducer(&p)) {
p.set("ttl", 1);
p.set("length", qRound(MLT.profile().fps() * 600));
p.set("out", qRound(MLT.profile().fps() * Settings.imageDuration()) - 1);
Expand Down
13 changes: 10 additions & 3 deletions src/mltcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ int Controller::open(const QString &url)
(m_producer->get_int("_original_type") == tractor_type && m_producer->get("shotcut")))
m_url = url;
}
const char *service = m_producer->get("mlt_service");
if (service && (!strcmp(service, "pixbuf") || !strcmp(service, "qimage"))) {
if (MLT.isImageProducer()) {
m_producer->set("length", qRound(profile().fps() * 600));
m_producer->set("out", qRound(profile().fps() * Settings.imageDuration()) - 1);
}
Expand Down Expand Up @@ -525,7 +524,15 @@ bool Controller::isMultitrack() const
return m_producer && m_producer->is_valid()
&& !m_producer->get_int(kShotcutVirtualClip)
&& (m_producer->get_int("_original_type") == tractor_type || resource() == "<tractor>")
&& (m_producer->get("shotcut"));
&& (m_producer->get("shotcut"));
}

bool Controller::isImageProducer(Service* service) const
{
if (!service)
service = (Service*) m_producer;
QString serviceName = service->get("mlt_service");
return (serviceName == "pixbuf" || serviceName == "qimage");
}

void Controller::rewind()
Expand Down
1 change: 1 addition & 0 deletions src/mltcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class Controller
bool isSeekableClip();
bool isPlaylist() const;
bool isMultitrack() const;
bool isImageProducer(Service* service = 0) const;
void rewind();
void fastForward();
void previous(int currentPosition);
Expand Down

0 comments on commit 6c49a67

Please sign in to comment.