]>
iEval git - io-compress-brotli.git/blob - Brotli.pm
87049017ab1c9caa4256df8cb5dba1f1e168dba5
1 package IO
::Compress
::Brotli
;
6 use parent qw
/Exporter/;
8 use IO
::Uncompress
::Brotli
;
10 our @EXPORT = qw
/bro/;
11 our @EXPORT_OK = @EXPORT;
13 our $VERSION = '0.002';
15 my %BROTLI_ENCODER_MODE = ( generic
=> 0, text
=> 1, font
=> 2 );
17 my ($self, $mode) = @_;
19 die "Invalid encoder mode"
20 unless $BROTLI_ENCODER_MODE{$mode};
33 IO::Compress::Brotli - Write Brotli buffers/streams
37 use IO::Compress::Brotli;
40 my $encoded = bro $encoded;
43 my $bro = IO::Compress::Brotli->create;
45 my $block = get_input_block();
46 my $encoded_block = $bro->compress($block);
47 handle_output_block($encoded_block);
49 # Need to finish the steam
50 handle_output_block($bro->finish());
54 IO::Compress::Brotli is a module that compressed Brotli buffers
55 and streams. Despite its name, it is not a subclass of
56 L<IO::Compress::Base> and does not implement its interface. This
57 will be rectified in a future release.
59 =head2 One-shot interface
61 If you have the whole buffer in a Perl scalar use the B<bro>
66 =item B<bro>(I<$input>)
68 Takes a whole uncompressed buffer as input and returns the compressed
75 =head2 Streaming interface
77 If you want to process the data in blocks use the object oriented
78 interface. The available methods are:
82 =item IO::Compress::Brotli->B<create>
84 Returns a IO::Compress::Brotli instance. Please note that a single
85 instance cannot be used to decompress multiple streams.
87 =item $bro->B<window>(I<$window>)
89 Sets the window parameter on the brotli encoder.
90 Defaults to BROTLI_DEFAULT_WINDOW (22).
92 =item $bro->B<quality>(I<$quality>)
94 Sets the quality paremeter on the brotli encoder.
95 Defaults to BROTLI_DEFAULT_QUALITY (11).
97 =item $bro->B<mode>(I<$mode>)
99 Sets the brotli encoder mode, which can be any of "generic",
100 "text" or "font". Defaults to "generic".
102 =item $bro->B<compress>(I<$block>)
104 Takes the a block of uncompressed data and returns a block of
105 compressed data. Dies on error.
107 =item $bro->B<flush>()
109 Flushes any pending output from the encoder.
111 =item $bro->B<finish>()
113 Tells the encoder to start the finish operation, and flushes
114 any remaining compressed output.
116 Once finish is called, the encoder cannot be used to compress
119 B<NOTE>: Calling finish is B<required>, or the output might
120 remain unflushed, and the be missing termination marks.
126 Brotli Compressed Data Format Internet-Draft:
127 L<https://www.ietf.org/id/draft-alakuijala-brotli-08.txt>
129 Brotli source code: L<https://github.com/google/brotli/>
133 Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
135 The encoder bindings, modernisation of the decoder bindings and a
136 clean up of the overall project were contributed by:
140 =item Quim Rovira, E<lt>quim@rovira.catE<gt>
142 =item Ævar Arnfjörð Bjarmason, E<lt>avarab@gmail.comE<gt>
144 =item Marcell Szathmári
146 =item Mattia Barbon, E<lt>mattia@barbon.orgE<gt>
150 =head1 COPYRIGHT AND LICENSE
152 Copyright (C) 2015-2016 by Marius Gavrilescu
154 This library is free software; you can redistribute it and/or modify
155 it under the same terms as Perl itself, either Perl version 5.20.2 or,
156 at your option, any later version of Perl 5 you may have available.
This page took 0.057383 seconds and 3 git commands to generate.