2016-03-25 08:40:15 +00:00
|
|
|
// Copyright 2016 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// 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>
|
|
|
|
|
2017-08-02 20:37:47 +00:00
|
|
|
#include "packager/hls/public/hls_params.h"
|
2016-03-25 08:40:15 +00:00
|
|
|
#include "packager/mpd/base/media_info.pb.h"
|
|
|
|
|
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:
|
2017-06-30 20:42:46 +00:00
|
|
|
explicit HlsNotifier(HlsPlaylistType playlist_type)
|
|
|
|
: playlist_type_(playlist_type) {}
|
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;
|
|
|
|
|
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,
|
|
|
|
uint64_t start_time,
|
|
|
|
uint64_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-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.
|
|
|
|
virtual bool NotifyCueEvent(uint32_t stream_id, uint64_t timestamp) = 0;
|
|
|
|
|
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;
|
|
|
|
|
2017-06-30 20:42:46 +00:00
|
|
|
/// @return the playlist type.
|
|
|
|
HlsPlaylistType playlist_type() const { return playlist_type_; }
|
2016-03-25 08:40:15 +00:00
|
|
|
|
|
|
|
private:
|
2017-06-30 20:42:46 +00:00
|
|
|
HlsPlaylistType playlist_type_;
|
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_
|