Shaka Packager SDK
packed_audio_writer.h
1 // Copyright 2018 Google LLC. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file or at
5 // https://developers.google.com/open-source/licenses/bsd
6 
7 #ifndef PACKAGER_MEDIA_FORMATS_PACKED_AUDIO_PACKED_AUDIO_WRITER_H_
8 #define PACKAGER_MEDIA_FORMATS_PACKED_AUDIO_PACKED_AUDIO_WRITER_H_
9 
10 #include "packager/file/file_closer.h"
11 #include "packager/media/base/muxer.h"
12 
13 namespace shaka {
14 namespace media {
15 
16 class BufferWriter;
17 class PackedAudioSegmenter;
18 
23 class PackedAudioWriter : public Muxer {
24  public:
26  explicit PackedAudioWriter(const MuxerOptions& muxer_options);
27  ~PackedAudioWriter() override;
28 
29  private:
30  friend class PackedAudioWriterTest;
31 
32  PackedAudioWriter(const PackedAudioWriter&) = delete;
33  PackedAudioWriter& operator=(const PackedAudioWriter&) = delete;
34 
35  // Muxer implementations.
36  Status InitializeMuxer() override;
37  Status Finalize() override;
38  Status AddSample(size_t stream_id, const MediaSample& sample) override;
39  Status FinalizeSegment(size_t stream_id, const SegmentInfo& sample) override;
40 
41  Status WriteSegment(const std::string& segment_path,
42  BufferWriter* segment_buffer);
43 
44  Status CloseFile(std::unique_ptr<File, FileCloser> file);
45 
46  std::unique_ptr<PackedAudioSegmenter> segmenter_;
47 
48  // Used in single segment mode.
49  std::unique_ptr<File, FileCloser> output_file_;
50  // Keeps track of segment ranges in single segment mode.
51  MuxerListener::MediaRanges media_ranges_;
52  uint64_t total_duration_ = 0;
53 
54  // Used in multi-segment mode for segment template.
55  uint64_t segment_number_ = 0;
56 };
57 
58 } // namespace media
59 } // namespace shaka
60 
61 #endif // PACKAGER_MEDIA_FORMATS_PACKED_AUDIO_PACKED_AUDIO_WRITER_H_
All the methods that are virtual are virtual for mocking.
This structure contains the list of configuration options for Muxer.
Definition: muxer_options.h:20
PackedAudioWriter(const MuxerOptions &muxer_options)
Create a MP4Muxer object from MuxerOptions.
Class to hold a media sample.
Definition: media_sample.h:22