|
@@ -10,6 +10,7 @@ namespace Publicate.Wizards {
|
|
|
private EntryRow author;
|
|
|
private EntryRow author_email;
|
|
|
private ThumbnailChooserRow thumbnail_file;
|
|
|
+ private ProprietaryCodecsRow proprietary_codecs;
|
|
|
|
|
|
private ViewerWindow window;
|
|
|
|
|
@@ -48,6 +49,9 @@ namespace Publicate.Wizards {
|
|
|
author_email.title = "Author Email";
|
|
|
group.add(author_email);
|
|
|
|
|
|
+ proprietary_codecs = new ProprietaryCodecsRow(window);
|
|
|
+ group.add(proprietary_codecs);
|
|
|
+
|
|
|
append(group);
|
|
|
|
|
|
|
|
@@ -98,7 +102,7 @@ namespace Publicate.Wizards {
|
|
|
print(metadata.to_string());
|
|
|
|
|
|
var processor = new Video.VideoProcessor();
|
|
|
- var result = yield processor.process_video(video_file.selected_file.get_path(), window);
|
|
|
+ var result = yield processor.process_video(video_file.selected_file.get_path(), window, proprietary_codecs.use_proprietary_codecs);
|
|
|
|
|
|
result.manifest.author = metadata.author;
|
|
|
result.manifest.title = metadata.title;
|
|
@@ -129,12 +133,12 @@ namespace Publicate.Wizards {
|
|
|
builder.add_asset("video_description.md", "text/markdown", description_stream, Invercargill.empty<string>(), compression_info);
|
|
|
|
|
|
if(thumbnail_file.selected_file != null) {
|
|
|
- yield add_file(builder, thumbnail_file.selected_file);
|
|
|
+ yield add_file(builder, thumbnail_file.selected_file, Ppub.CompressionPolicy.AUTO);
|
|
|
print("Added file\n");
|
|
|
}
|
|
|
|
|
|
foreach (var result_file in result.video_files) {
|
|
|
- yield add_file(builder, result_file);
|
|
|
+ yield add_file(builder, result_file, Ppub.CompressionPolicy.NEVER_COMPRESS);
|
|
|
print("Added video file\n");
|
|
|
}
|
|
|
|
|
@@ -154,9 +158,9 @@ namespace Publicate.Wizards {
|
|
|
video_file.reset();
|
|
|
}
|
|
|
|
|
|
- private static async void add_file(Ppub.Builder builder, File file) throws Error {
|
|
|
+ private static async void add_file(Ppub.Builder builder, File file, Ppub.CompressionPolicy compression_policy) throws Error {
|
|
|
var stream = yield file.read_async(Priority.DEFAULT, null);
|
|
|
- var compression = new Ppub.CompressionInfo(stream, false);
|
|
|
+ var compression = new Ppub.CompressionInfo(stream, compression_policy);
|
|
|
stream.seek(0, SeekType.SET, null);
|
|
|
var sample = new uint8[2048];
|
|
|
size_t sample_size;
|
|
@@ -291,4 +295,57 @@ namespace Publicate.Wizards {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private class ProprietaryCodecsRow : ActionRow {
|
|
|
+ public bool use_proprietary_codecs { get; private set; }
|
|
|
+ private Switch gtk_switch;
|
|
|
+ private ViewerWindow toplevel;
|
|
|
+
|
|
|
+ public ProprietaryCodecsRow(ViewerWindow window) {
|
|
|
+ toplevel = window;
|
|
|
+ gtk_switch = new Switch();
|
|
|
+ gtk_switch.notify["active"].connect(confirm_change);
|
|
|
+ gtk_switch.vexpand = false;
|
|
|
+ gtk_switch.valign = Align.CENTER;
|
|
|
+ add_suffix(gtk_switch);
|
|
|
+ reset();
|
|
|
+
|
|
|
+ activatable_widget = gtk_switch;
|
|
|
+ activatable = true;
|
|
|
+
|
|
|
+ title = "Use Proprietary Codecs";
|
|
|
+ subtitle = "Compatible with more devices";
|
|
|
+ }
|
|
|
+
|
|
|
+ public void confirm_change() {
|
|
|
+ if(!gtk_switch.active) {
|
|
|
+ use_proprietary_codecs = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var prompt = new Adw.MessageDialog(toplevel, "Enable Proprietary Codecs?", "This will enable the H.264 codec which is needed for this PPUB to be playable on iOS Safari, but there may be restrictive patient licences that apply to its use.");
|
|
|
+ prompt.add_response("info", "Read More");
|
|
|
+ prompt.add_response("cancel", "Cancel");
|
|
|
+ prompt.add_response("enable", "Enable");
|
|
|
+ prompt.response.connect(r => {
|
|
|
+ if(r == "info") {
|
|
|
+ var uri = Uri.parse("https://www.fsf.org/licensing/h264-patent-license", UriFlags.PARSE_RELAXED);
|
|
|
+ var app = AppInfo.get_default_for_uri_scheme(uri.get_scheme());
|
|
|
+ var uris = new List<string>();
|
|
|
+ uris.append(uri.to_string());
|
|
|
+ app.launch_uris(uris, null);
|
|
|
+ }
|
|
|
+ if(r != "enable") {
|
|
|
+ gtk_switch.active = false;
|
|
|
+ }
|
|
|
+ prompt.close();
|
|
|
+ use_proprietary_codecs = gtk_switch.active;
|
|
|
+ });
|
|
|
+ prompt.present();
|
|
|
+ }
|
|
|
+
|
|
|
+ public void reset() {
|
|
|
+ use_proprietary_codecs = false;
|
|
|
+ gtk_switch.active = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|