2022-08-26 15:44:59 +00:00
|
|
|
// Copyright 2016 Google LLC. All rights reserved.
|
2016-03-25 08:40:15 +00:00
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file or at
|
|
|
|
// https://developers.google.com/open-source/licenses/bsd
|
|
|
|
|
|
|
|
#ifndef PACKAGER_HLS_BASE_HLS_NOTIFIER_H_
|
|
|
|
#define PACKAGER_HLS_BASE_HLS_NOTIFIER_H_
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2023-10-10 23:51:11 +00:00
|
|
|
#include <packager/hls/public/hls_params.h>
|
|
|
|
#include <packager/mpd/base/media_info.pb.h>
|
2016-03-25 08:40:15 +00:00
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2016-03-25 08:40:15 +00:00
|
|
|
namespace hls {
|
|
|
|
|
|
|
|
// TODO(rkuroiwa): Consider merging this with MpdNotifier.
|
|
|
|
class HlsNotifier {
|
|
|
|
public:
|
2018-04-14 01:26:02 +00:00
|
|
|
explicit HlsNotifier(const HlsParams& hls_params) : hls_params_(hls_params) {}
|
2016-03-25 08:40:15 +00:00
|
|
|
virtual ~HlsNotifier() {}
|
|
|
|
|
|
|
|
/// Intialize the notifier.
|
|
|
|
/// @return true on sucess, false otherwise.
|
|
|
|
virtual bool Init() = 0;
|
|
|
|
|
|
|
|
/// @param media_info specifies the stream.
|
|
|
|
/// @param playlist_name is the name of the playlist that this stream should
|
|
|
|
/// go.
|
|
|
|
/// @param stream_name is the name of this stream.
|
|
|
|
/// @param group_id is the group ID for this stream.
|
|
|
|
/// @param stream_id is set to a value so that it can be used to call the
|
|
|
|
/// other methods. If this returns false, the stream_id may be set to
|
|
|
|
/// an invalid value.
|
|
|
|
/// @return true on sucess, false otherwise.
|
|
|
|
virtual bool NotifyNewStream(const MediaInfo& media_info,
|
|
|
|
const std::string& playlist_name,
|
|
|
|
const std::string& stream_name,
|
|
|
|
const std::string& group_id,
|
|
|
|
uint32_t* stream_id) = 0;
|
|
|
|
|
2019-09-23 06:47:07 +00:00
|
|
|
/// Change the sample duration of stream with @a stream_id.
|
|
|
|
/// @param stream_id is the value set by NotifyNewStream().
|
|
|
|
/// @param sample_duration is the duration of a sample in timescale of the
|
|
|
|
/// media.
|
|
|
|
/// @return true on success, false otherwise. This may fail if the stream
|
|
|
|
/// specified by @a stream_id does not exist.
|
|
|
|
virtual bool NotifySampleDuration(uint32_t stream_id,
|
2021-08-04 18:56:44 +00:00
|
|
|
int32_t sample_duration) = 0;
|
2019-09-23 06:47:07 +00:00
|
|
|
|
2017-05-01 20:38:58 +00:00
|
|
|
/// @param stream_id is the value set by NotifyNewStream().
|
|
|
|
/// @param segment_name is the name of the new segment.
|
|
|
|
/// @param start_time is the start time of the segment in timescale units
|
|
|
|
/// passed in @a media_info.
|
|
|
|
/// @param duration is also in terms of timescale.
|
|
|
|
/// @param start_byte_offset is the offset of where the subsegment starts.
|
|
|
|
/// This should be 0 if the whole segment is a subsegment.
|
|
|
|
/// @param size is the size in bytes.
|
2016-03-25 08:40:15 +00:00
|
|
|
virtual bool NotifyNewSegment(uint32_t stream_id,
|
|
|
|
const std::string& segment_name,
|
2021-08-04 18:56:44 +00:00
|
|
|
int64_t start_time,
|
|
|
|
int64_t duration,
|
2017-05-01 20:38:58 +00:00
|
|
|
uint64_t start_byte_offset,
|
2016-03-25 08:40:15 +00:00
|
|
|
uint64_t size) = 0;
|
|
|
|
|
2018-01-31 02:30:19 +00:00
|
|
|
/// Called on every key frame. For Video only.
|
|
|
|
/// @param stream_id is the value set by NotifyNewStream().
|
|
|
|
/// @param timestamp is the timesamp of the key frame in timescale units
|
|
|
|
/// passed in @a media_info.
|
|
|
|
/// @param start_byte_offset is the offset of where the keyframe starts.
|
|
|
|
/// @param size is the size in bytes.
|
|
|
|
virtual bool NotifyKeyFrame(uint32_t stream_id,
|
2021-08-04 18:56:44 +00:00
|
|
|
int64_t timestamp,
|
2018-01-31 02:30:19 +00:00
|
|
|
uint64_t start_byte_offset,
|
|
|
|
uint64_t size) = 0;
|
|
|
|
|
2018-01-03 00:10:33 +00:00
|
|
|
/// @param stream_id is the value set by NotifyNewStream().
|
|
|
|
/// @param timestamp is the timestamp of the CueEvent.
|
|
|
|
/// @return true on success, false otherwise.
|
2021-08-04 18:56:44 +00:00
|
|
|
virtual bool NotifyCueEvent(uint32_t stream_id, int64_t timestamp) = 0;
|
2018-01-03 00:10:33 +00:00
|
|
|
|
2016-03-25 08:40:15 +00:00
|
|
|
/// @param stream_id is the value set by NotifyNewStream().
|
|
|
|
/// @param key_id is the key ID for the stream.
|
|
|
|
/// @param system_id is the DRM system ID in e.g. PSSH boxes. For example this
|
|
|
|
/// can be used to determine the KEYFORMAT attribute for EXT-X-KEY.
|
|
|
|
/// @param iv is the new initialization vector.
|
|
|
|
/// @param protection_system_specific_data is the DRM specific data. The
|
|
|
|
/// interpretation of this data is up to the implementation, possibly
|
|
|
|
/// using @a system_id to determine how to interpret the data.
|
|
|
|
virtual bool NotifyEncryptionUpdate(
|
|
|
|
uint32_t stream_id,
|
|
|
|
const std::vector<uint8_t>& key_id,
|
|
|
|
const std::vector<uint8_t>& system_id,
|
|
|
|
const std::vector<uint8_t>& iv,
|
|
|
|
const std::vector<uint8_t>& protection_system_specific_data) = 0;
|
|
|
|
|
|
|
|
/// Process any current buffered states/resources.
|
|
|
|
/// @return true on success, false otherwise.
|
|
|
|
virtual bool Flush() = 0;
|
|
|
|
|
2018-04-14 01:26:02 +00:00
|
|
|
/// @return The HLS parameters.
|
|
|
|
const HlsParams& hls_params() const { return hls_params_; }
|
2016-03-25 08:40:15 +00:00
|
|
|
|
|
|
|
private:
|
2018-04-14 01:26:02 +00:00
|
|
|
const HlsParams hls_params_;
|
2016-03-25 08:40:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace hls
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|
2017-06-30 20:42:46 +00:00
|
|
|
|
2016-03-25 08:40:15 +00:00
|
|
|
#endif // PACKAGER_HLS_BASE_HLS_NOTIFIER_H_
|