Shaka Packager SDK
muxer_listener.h
1 // Copyright 2014 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 // Event handler for events fired by Muxer.
8 
9 #ifndef PACKAGER_MEDIA_EVENT_MUXER_LISTENER_H_
10 #define PACKAGER_MEDIA_EVENT_MUXER_LISTENER_H_
11 
12 #include <cstdint>
13 #include <optional>
14 #include <string>
15 #include <vector>
16 
17 #include <packager/macros/classes.h>
18 #include <packager/macros/compiler.h>
19 #include <packager/media/base/fourccs.h>
20 #include <packager/media/base/range.h>
21 
22 namespace shaka {
23 namespace media {
24 
25 struct MuxerOptions;
26 struct ProtectionSystemSpecificInfo;
27 class StreamInfo;
28 
34  public:
35  enum ContainerType {
36  kContainerUnknown = 0,
37  kContainerMp4,
38  kContainerMpeg2ts,
39  kContainerWebM,
40  kContainerText,
41  kContainerPackedAudio,
42  };
43 
47  struct MediaRanges {
49  std::optional<Range> init_range;
51  std::optional<Range> index_range;
55  std::vector<Range> subsegment_ranges;
56  };
57 
58  virtual ~MuxerListener() = default;
59 
78  virtual void OnEncryptionInfoReady(
79  bool is_initial_encryption_info,
80  FourCC protection_scheme,
81  const std::vector<uint8_t>& key_id,
82  const std::vector<uint8_t>& iv,
83  const std::vector<ProtectionSystemSpecificInfo>& key_system_info) = 0;
84 
89  virtual void OnEncryptionStart() = 0;
90 
99  virtual void OnMediaStart(const MuxerOptions& muxer_options,
100  const StreamInfo& stream_info,
101  int32_t time_scale,
102  ContainerType container_type) = 0;
103 
105  virtual void OnAvailabilityOffsetReady() {}
106 
109  virtual void OnSampleDurationReady(int32_t sample_duration) = 0;
110 
112  virtual void OnSegmentDurationReady() {}
113 
120  virtual void OnMediaEnd(const MediaRanges& media_ranges,
121  float duration_seconds) = 0;
122 
137  virtual void OnNewSegment(const std::string& segment_name,
138  int64_t start_time,
139  int64_t duration,
140  uint64_t segment_file_size,
141  int64_t segment_number) = 0;
142 
149  virtual void OnCompletedSegment(int64_t duration,
150  uint64_t segment_file_size) {
151  UNUSED(duration);
152  UNUSED(segment_file_size);
153  }
154 
160  virtual void OnKeyFrame(int64_t timestamp,
161  uint64_t start_byte_offset,
162  uint64_t size) = 0;
163 
167  virtual void OnCueEvent(int64_t timestamp, const std::string& cue_data) = 0;
168 
169  protected:
170  MuxerListener() = default;
171 };
172 
173 } // namespace media
174 } // namespace shaka
175 
176 #endif // PACKAGER_MEDIA_EVENT_MUXER_LISTENER_H_
virtual void OnMediaEnd(const MediaRanges &media_ranges, float duration_seconds)=0
virtual void OnAvailabilityOffsetReady()
Called when LL-DASH streaming starts.
virtual void OnCompletedSegment(int64_t duration, uint64_t segment_file_size)
virtual void OnMediaStart(const MuxerOptions &muxer_options, const StreamInfo &stream_info, int32_t time_scale, ContainerType container_type)=0
virtual void OnNewSegment(const std::string &segment_name, int64_t start_time, int64_t duration, uint64_t segment_file_size, int64_t segment_number)=0
virtual void OnSegmentDurationReady()
Called when LL-DASH streaming starts.
virtual void OnEncryptionStart()=0
virtual void OnSampleDurationReady(int32_t sample_duration)=0
virtual void OnCueEvent(int64_t timestamp, const std::string &cue_data)=0
virtual void OnEncryptionInfoReady(bool is_initial_encryption_info, FourCC protection_scheme, const std::vector< uint8_t > &key_id, const std::vector< uint8_t > &iv, const std::vector< ProtectionSystemSpecificInfo > &key_system_info)=0
virtual void OnKeyFrame(int64_t timestamp, uint64_t start_byte_offset, uint64_t size)=0
Abstract class holds stream information.
Definition: stream_info.h:71
All the methods that are virtual are virtual for mocking.
Definition: crypto_flags.cc:66
std::optional< Range > index_range
Range of the index section of a segment.
std::optional< Range > init_range
Range of the initialization section of a segment.
This structure contains the list of configuration options for Muxer.
Definition: muxer_options.h:19