2
* Copyright (C) 2015 Canonical Ltd.
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 3 as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: James Henstridge <james.henstridge@canonical.com>
23
#pragma GCC diagnostic push
24
#pragma GCC diagnostic ignored "-Wold-style-cast"
25
#pragma GCC diagnostic ignored "-Wcast-qual"
26
#pragma GCC diagnostic ignored "-Wcast-align"
30
#pragma GCC diagnostic pop
32
#include "thumbnailextractor.h"
35
using namespace unity::thumbnailer::internal;
40
string command_line_arg_to_uri(string const& arg)
42
unique_ptr<GFile, decltype(&g_object_unref)> file(g_file_new_for_commandline_arg(arg.c_str()), g_object_unref);
45
throw runtime_error("Could not create parse argument as file");
47
char* c_uri = g_file_get_uri(file.get());
50
throw runtime_error("Could not convert to uri");
59
int main(int argc, char** argv)
61
gst_init(&argc, &argv);
63
std::unique_ptr<GMainLoop, decltype(&g_main_loop_unref)> main_loop(
64
g_main_loop_new(nullptr, false), g_main_loop_unref);
66
ThumbnailExtractor extractor;
67
for (int i = 1; i < argc; i++)
72
uri = command_line_arg_to_uri(argv[i]);
74
catch (exception const& e)
76
fprintf(stderr, "Error parsing \"%s\": %s\n", argv[i], e.what());
79
printf("Extracting from %s\n", uri.c_str());
82
extractor.set_uri(uri);
83
if (extractor.has_video())
85
success = extractor.extract_video_frame();
89
success = extractor.extract_audio_cover_art();
92
catch (exception const& e)
94
fprintf(stderr, "Error extracting content \"%s\": %s\n", argv[1], e.what());
100
return success ? 0 : 1;