1 #include "test_utils.hpp"
2 
createProducer(Mlt::Profile & prof,std::string color,std::shared_ptr<ProjectItemModel> binModel,int length,bool limited)3 QString createProducer(Mlt::Profile &prof, std::string color, std::shared_ptr<ProjectItemModel> binModel, int length, bool limited)
4 {
5     std::shared_ptr<Mlt::Producer> producer = std::make_shared<Mlt::Producer>(prof, "color", color.c_str());
6     producer->set("length", length);
7     producer->set("out", length - 1);
8 
9     REQUIRE(producer->is_valid());
10 
11     QString binId = QString::number(binModel->getFreeClipId());
12     auto binClip = ProjectClip::construct(binId, QIcon(), binModel, producer);
13     if (limited) {
14         binClip->forceLimitedDuration();
15     }
16     Fun undo = []() { return true; };
17     Fun redo = []() { return true; };
18     REQUIRE(binModel->addItem(binClip, binModel->getRootFolder()->clipId(), undo, redo));
19 
20     return binId;
21 }
22 
createProducerWithSound(Mlt::Profile & prof,std::shared_ptr<ProjectItemModel> binModel,int length)23 QString createProducerWithSound(Mlt::Profile &prof, std::shared_ptr<ProjectItemModel> binModel, int length)
24 {
25     // std::shared_ptr<Mlt::Producer> producer = std::make_shared<Mlt::Producer>(prof,
26     // QFileInfo("../tests/small.mkv").absoluteFilePath().toStdString().c_str());
27 
28     // In case the test system does not have avformat support, we can switch to the integrated blipflash producer
29     std::shared_ptr<Mlt::Producer> producer = std::make_shared<Mlt::Producer>(prof, "blipflash");
30     producer->set("length", length);
31     producer->set_in_and_out(0, length - 1);
32     producer->set("kdenlive:duration", length);
33 
34     REQUIRE(producer->is_valid());
35 
36     QString binId = QString::number(binModel->getFreeClipId());
37     auto binClip = ProjectClip::construct(binId, QIcon(), binModel, producer);
38     binClip->forceLimitedDuration();
39     Fun undo = []() { return true; };
40     Fun redo = []() { return true; };
41     REQUIRE(binModel->addItem(binClip, binModel->getRootFolder()->clipId(), undo, redo));
42 
43     return binId;
44 }
45