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 AddMediaSample(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  const int32_t transport_stream_timestamp_offset_ = 0;
47  std::unique_ptr<PackedAudioSegmenter> segmenter_;
48 
49  // Used in single segment mode.
50  std::unique_ptr<File, FileCloser> output_file_;
51  // Keeps track of segment ranges in single segment mode.
52  MuxerListener::MediaRanges media_ranges_;
53  int64_t total_duration_ = 0;
54 
55  // Used in multi-segment mode for segment template.
56  uint64_t segment_number_ = 0;
57 };
58 
59 } // namespace media
60 } // namespace shaka
61 
62 #endif // PACKAGER_MEDIA_FORMATS_PACKED_AUDIO_PACKED_AUDIO_WRITER_H_
Class to hold a media sample.
Definition: media_sample.h:25
PackedAudioWriter(const MuxerOptions &muxer_options)
Create a MP4Muxer object from MuxerOptions.
All the methods that are virtual are virtual for mocking.
Definition: crypto_flags.cc:66
This structure contains the list of configuration options for Muxer.
Definition: muxer_options.h:19