2022-08-26 15:44:59 +00:00
|
|
|
// Copyright 2014 Google LLC. All rights reserved.
|
2014-02-14 23:21:05 +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
|
|
|
|
//
|
2013-12-05 23:13:35 +00:00
|
|
|
// MpdNotifier is responsible for notifying the MpdBuilder class to generate an
|
|
|
|
// MPD file.
|
2014-02-14 23:21:05 +00:00
|
|
|
|
2013-12-05 23:13:35 +00:00
|
|
|
#ifndef MPD_BASE_MPD_NOTIFIER_H_
|
|
|
|
#define MPD_BASE_MPD_NOTIFIER_H_
|
|
|
|
|
2014-09-30 23:52:58 +00:00
|
|
|
#include <stdint.h>
|
2023-07-13 23:25:42 +00:00
|
|
|
|
2015-09-24 22:03:52 +00:00
|
|
|
#include <string>
|
2015-08-26 20:25:29 +00:00
|
|
|
#include <vector>
|
2013-12-05 23:13:35 +00:00
|
|
|
|
2023-10-10 23:51:11 +00:00
|
|
|
#include <packager/macros.h>
|
|
|
|
#include <packager/mpd/base/mpd_options.h>
|
2015-07-22 06:57:21 +00:00
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2013-12-05 23:13:35 +00:00
|
|
|
|
|
|
|
class MediaInfo;
|
2014-05-19 21:30:58 +00:00
|
|
|
struct ContentProtectionElement;
|
2013-12-05 23:13:35 +00:00
|
|
|
|
2014-02-06 21:20:36 +00:00
|
|
|
/// Interface for publish/subscribe publisher class which notifies MpdBuilder
|
|
|
|
/// of media-related events.
|
2013-12-05 23:13:35 +00:00
|
|
|
class MpdNotifier {
|
|
|
|
public:
|
2016-12-21 23:28:56 +00:00
|
|
|
explicit MpdNotifier(const MpdOptions& mpd_options)
|
|
|
|
: mpd_options_(mpd_options) {}
|
|
|
|
virtual ~MpdNotifier() {}
|
2013-12-05 23:13:35 +00:00
|
|
|
|
2014-02-06 21:20:36 +00:00
|
|
|
/// Initializes the notifier. For example, if this notifier uses a network for
|
|
|
|
/// notification, then this would set up the connection with the remote host.
|
|
|
|
/// @return true on success, false otherwise.
|
2013-12-05 23:13:35 +00:00
|
|
|
virtual bool Init() = 0;
|
|
|
|
|
2014-02-06 21:20:36 +00:00
|
|
|
/// Notifies the MpdBuilder that there is a new container along with
|
|
|
|
/// @a media_info. Live may have multiple files (segments) but those should be
|
|
|
|
/// notified via NotifyNewSegment().
|
|
|
|
/// @param media_info is the MediaInfo that will be passed to MpdBuilder.
|
|
|
|
/// @param[out] container_id is the numeric ID of the container, possibly for
|
|
|
|
/// NotifyNewSegment() and AddContentProtectionElement(). Only
|
|
|
|
/// populated on success.
|
|
|
|
/// @return true on success, false otherwise.
|
2013-12-05 23:13:35 +00:00
|
|
|
virtual bool NotifyNewContainer(const MediaInfo& media_info,
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t* container_id) = 0;
|
2013-12-05 23:13:35 +00:00
|
|
|
|
2021-08-25 15:38:05 +00:00
|
|
|
/// Record the availailityTimeOffset for Low Latency DASH streaming.
|
|
|
|
/// @param container_id Container ID obtained from calling
|
|
|
|
/// NotifyNewContainer().
|
|
|
|
/// @return true on success, false otherwise. This may fail if the container
|
|
|
|
/// specified by @a container_id does not exist.
|
|
|
|
virtual bool NotifyAvailabilityTimeOffset(uint32_t container_id) {
|
2023-07-13 23:25:42 +00:00
|
|
|
UNUSED(container_id);
|
2021-08-25 15:38:05 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-06-15 21:12:42 +00:00
|
|
|
/// Change the sample duration of container with @a container_id.
|
|
|
|
/// @param container_id Container ID obtained from calling
|
|
|
|
/// NotifyNewContainer().
|
|
|
|
/// @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 container
|
|
|
|
/// specified by @a container_id does not exist.
|
|
|
|
virtual bool NotifySampleDuration(uint32_t container_id,
|
2021-08-04 18:56:44 +00:00
|
|
|
int32_t sample_duration) = 0;
|
2015-06-15 21:12:42 +00:00
|
|
|
|
2021-08-25 15:38:05 +00:00
|
|
|
/// Record the duration of a segment for Low Latency DASH streaming.
|
|
|
|
/// @param container_id Container ID obtained from calling
|
|
|
|
/// NotifyNewContainer().
|
|
|
|
/// @return true on success, false otherwise. This may fail if the container
|
|
|
|
/// specified by @a container_id does not exist.
|
2023-07-13 23:25:42 +00:00
|
|
|
virtual bool NotifySegmentDuration(uint32_t container_id) {
|
|
|
|
UNUSED(container_id);
|
|
|
|
return true;
|
|
|
|
}
|
2021-08-25 15:38:05 +00:00
|
|
|
|
2015-07-21 21:52:20 +00:00
|
|
|
/// Notifies MpdBuilder that there is a new segment ready. For live, this
|
2021-09-03 16:57:43 +00:00
|
|
|
/// is usually a new segment, for VOD this is usually a subsegment, for low
|
|
|
|
/// latency this is the first chunk.
|
2014-02-06 21:20:36 +00:00
|
|
|
/// @param container_id Container ID obtained from calling
|
|
|
|
/// NotifyNewContainer().
|
|
|
|
/// @param start_time is the start time of the new segment, in units of the
|
|
|
|
/// stream's time scale.
|
|
|
|
/// @param duration is the duration of the new segment, in units of the
|
2014-05-30 05:01:09 +00:00
|
|
|
/// stream's time scale.
|
|
|
|
/// @param size is the new segment size in bytes.
|
2014-02-06 21:20:36 +00:00
|
|
|
/// @return true on success, false otherwise.
|
2014-09-30 21:52:21 +00:00
|
|
|
virtual bool NotifyNewSegment(uint32_t container_id,
|
2021-08-04 18:56:44 +00:00
|
|
|
int64_t start_time,
|
|
|
|
int64_t duration,
|
2014-09-30 21:52:21 +00:00
|
|
|
uint64_t size) = 0;
|
2013-12-05 23:13:35 +00:00
|
|
|
|
2021-09-03 16:57:43 +00:00
|
|
|
/// Notifies MpdBuilder that a segment is fully written and provides the
|
|
|
|
/// segment's complete duration and size. For Low Latency only. Note, size and
|
|
|
|
/// duration are not known when the low latency segment is first registered
|
|
|
|
/// with the MPD, so we must update these values after the segment is
|
|
|
|
/// complete.
|
|
|
|
/// @param container_id Container ID obtained from calling
|
|
|
|
/// NotifyNewContainer().
|
|
|
|
/// @param duration is the duration of the complete segment, in units of the
|
|
|
|
/// stream's time scale.
|
|
|
|
/// @param size is the complete segment size in bytes.
|
|
|
|
/// @return true on success, false otherwise.
|
|
|
|
virtual bool NotifyCompletedSegment(uint32_t container_id,
|
|
|
|
int64_t duration,
|
|
|
|
uint64_t size) {
|
2023-07-13 23:25:42 +00:00
|
|
|
UNUSED(container_id);
|
|
|
|
UNUSED(duration);
|
|
|
|
UNUSED(size);
|
2021-09-03 16:57:43 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-01-03 00:10:33 +00:00
|
|
|
/// Notifies MpdBuilder that there is a new CueEvent.
|
|
|
|
/// @param container_id Container ID obtained from calling
|
|
|
|
/// NotifyNewContainer().
|
|
|
|
/// @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 container_id, int64_t timestamp) = 0;
|
2018-01-03 00:10:33 +00:00
|
|
|
|
2015-08-26 20:25:29 +00:00
|
|
|
/// Notifiers MpdBuilder that there is a new PSSH for the container.
|
|
|
|
/// This may be called whenever the key has to change, e.g. key rotation.
|
|
|
|
/// @param container_id Container ID obtained from calling
|
|
|
|
/// NotifyNewContainer().
|
2015-09-24 22:03:52 +00:00
|
|
|
/// @param drm_uuid is the UUID of the DRM for encryption.
|
2015-08-26 20:25:29 +00:00
|
|
|
/// @param new_key_id is the new key ID for the key.
|
|
|
|
/// @param new_pssh is the new pssh box (including the header).
|
|
|
|
/// @attention This might change or get removed once DASH IF IOP specification
|
|
|
|
/// writes a clear guideline on how to handle key rotation.
|
|
|
|
virtual bool NotifyEncryptionUpdate(uint32_t container_id,
|
2015-09-24 22:03:52 +00:00
|
|
|
const std::string& drm_uuid,
|
2015-08-26 20:25:29 +00:00
|
|
|
const std::vector<uint8_t>& new_key_id,
|
|
|
|
const std::vector<uint8_t>& new_pssh) = 0;
|
|
|
|
|
2018-05-22 00:39:21 +00:00
|
|
|
/// @param container_id Container ID obtained from calling
|
|
|
|
/// NotifyNewContainer().
|
|
|
|
/// @param media_info is the new MediaInfo. Note that codec related
|
|
|
|
/// information cannot be updated.
|
|
|
|
virtual bool NotifyMediaInfoUpdate(uint32_t container_id,
|
|
|
|
const MediaInfo& media_info) = 0;
|
|
|
|
|
2015-09-10 23:01:00 +00:00
|
|
|
/// Call this method to force a flush. Implementations might not write out
|
|
|
|
/// the MPD to a stream (file, stdout, etc.) when the MPD is updated, this
|
|
|
|
/// forces a flush.
|
|
|
|
virtual bool Flush() = 0;
|
|
|
|
|
2020-04-17 17:20:03 +00:00
|
|
|
/// @return include_mspr_pro option flag
|
|
|
|
bool include_mspr_pro() const { return mpd_options_.mpd_params.include_mspr_pro; }
|
|
|
|
|
2014-05-16 23:32:10 +00:00
|
|
|
/// @return The dash profile for this object.
|
2016-12-21 23:28:56 +00:00
|
|
|
DashProfile dash_profile() const { return mpd_options_.dash_profile; }
|
|
|
|
|
|
|
|
/// @return The mpd type for this object.
|
|
|
|
MpdType mpd_type() const { return mpd_options_.mpd_type; }
|
2014-05-16 23:32:10 +00:00
|
|
|
|
2021-05-25 19:08:58 +00:00
|
|
|
/// @return The value of dash_force_segment_list flag
|
|
|
|
bool use_segment_list() const {
|
|
|
|
return mpd_options_.mpd_params.use_segment_list;
|
|
|
|
}
|
|
|
|
|
2014-05-16 23:32:10 +00:00
|
|
|
private:
|
2016-12-21 23:28:56 +00:00
|
|
|
const MpdOptions mpd_options_;
|
2014-05-16 23:32:10 +00:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(MpdNotifier);
|
2013-12-05 23:13:35 +00:00
|
|
|
};
|
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|
2013-12-05 23:13:35 +00:00
|
|
|
|
|
|
|
#endif // MPD_BASE_MPD_NOTIFIER_H_
|