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 uint32_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  uint64_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_
shaka::media::BufferWriter
Definition: buffer_writer.h:23
shaka::media::Muxer
Definition: muxer.h:30
shaka::media::PackedAudioWriter
Definition: packed_audio_writer.h:23
shaka::media::SegmentInfo
Definition: media_handler.h:55
shaka
All the methods that are virtual are virtual for mocking.
Definition: gflags_hex_bytes.cc:11
shaka::Status
Definition: status.h:110
shaka::media::MuxerOptions
This structure contains the list of configuration options for Muxer.
Definition: muxer_options.h:20
shaka::media::MuxerListener::MediaRanges
Definition: muxer_listener.h:46
shaka::media::PackedAudioWriter::PackedAudioWriter
PackedAudioWriter(const MuxerOptions &muxer_options)
Create a MP4Muxer object from MuxerOptions.
Definition: packed_audio_writer.cc:16
shaka::media::MediaSample
Class to hold a media sample.
Definition: media_sample.h:22