1 /*
2    mkvmerge -- utility for splicing together matroska files
3    from component media subtypes
4 
5    Distributed under the GPL v2
6    see the file COPYING for details
7    or visit https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
8 
9    class definition for the Vorbis packetizer
10 
11    Written by Moritz Bunkus <moritz@bunkus.org>.
12 */
13 
14 #pragma once
15 
16 #include "common/common_pch.h"
17 
18 #include <ogg/ogg.h>
19 #include <vorbis/codec.h>
20 
21 #include "merge/generic_packetizer.h"
22 
23 namespace mtx {
24   namespace output {
25     class vorbis_x: public exception {
26     protected:
27       std::string m_message;
28     public:
vorbis_x(const std::string & message)29       vorbis_x(const std::string &message) : m_message{message} { }
~vorbis_x()30       virtual ~vorbis_x() throw() { }
31 
what()32       virtual const char *what() const throw() {
33         return m_message.c_str();
34       }
35     };
36   }
37 }
38 
39 class vorbis_packetizer_c: public generic_packetizer_c {
40 private:
41   int64_t m_previous_bs{}, m_samples{}, m_previous_samples_sum{}, m_previous_timestamp{}, m_timestamp_offset{};
42   std::vector<memory_cptr> m_headers;
43   vorbis_info m_vi;
44   vorbis_comment m_vc;
45 
46 public:
47   vorbis_packetizer_c(generic_reader_c *reader, track_info_c &ti, std::vector<memory_cptr> const &headers);
48   virtual ~vorbis_packetizer_c();
49 
50   virtual void set_headers();
51 
get_format_name()52   virtual translatable_string_c get_format_name() const {
53     return YT("Vorbis");
54   }
55   virtual connection_result_e can_connect_to(generic_packetizer_c *src, std::string &error_message);
56 
57   virtual bool is_compatible_with(output_compatibility_e compatibility);
58 
59 protected:
60   virtual void process_impl(packet_cptr const &packet) override;
61 };
62