Pass hls_name and hls_group to HlsNotifyMuxerListener constructor
- Also don't Flush the notifier OnMediaEnd(). Change-Id: I2ffbbfacda74bb88678ac4e32b1f28c3e64eb85d
This commit is contained in:
parent
d06a9cd17c
commit
565affe7fb
|
@ -16,9 +16,15 @@
|
|||
namespace shaka {
|
||||
namespace media {
|
||||
|
||||
HlsNotifyMuxerListener::HlsNotifyMuxerListener(const std::string& playlist_name,
|
||||
HlsNotifyMuxerListener::HlsNotifyMuxerListener(
|
||||
const std::string& playlist_name,
|
||||
const std::string& ext_x_media_name,
|
||||
const std::string& ext_x_media_group_id,
|
||||
hls::HlsNotifier* hls_notifier)
|
||||
: playlist_name_(playlist_name), hls_notifier_(hls_notifier) {
|
||||
: playlist_name_(playlist_name),
|
||||
ext_x_media_name_(ext_x_media_name),
|
||||
ext_x_media_group_id_(ext_x_media_group_id),
|
||||
hls_notifier_(hls_notifier) {
|
||||
DCHECK(hls_notifier);
|
||||
}
|
||||
|
||||
|
@ -48,13 +54,12 @@ void HlsNotifyMuxerListener::OnMediaStart(const MuxerOptions& muxer_options,
|
|||
return;
|
||||
}
|
||||
const bool result = hls_notifier_->NotifyNewStream(
|
||||
media_info, playlist_name_, muxer_options.hls_name,
|
||||
muxer_options.hls_group_id, &stream_id_);
|
||||
media_info, playlist_name_, ext_x_media_name_, ext_x_media_group_id_,
|
||||
&stream_id_);
|
||||
LOG_IF(WARNING, !result) << "Failed to notify new stream.";
|
||||
}
|
||||
|
||||
void HlsNotifyMuxerListener::OnSampleDurationReady(uint32_t sample_duration) {
|
||||
}
|
||||
void HlsNotifyMuxerListener::OnSampleDurationReady(uint32_t sample_duration) {}
|
||||
|
||||
void HlsNotifyMuxerListener::OnMediaEnd(bool has_init_range,
|
||||
uint64_t init_range_start,
|
||||
|
@ -64,8 +69,9 @@ void HlsNotifyMuxerListener::OnMediaEnd(bool has_init_range,
|
|||
uint64_t index_range_end,
|
||||
float duration_seconds,
|
||||
uint64_t file_size) {
|
||||
const bool result = hls_notifier_->Flush();
|
||||
LOG_IF(WARNING, !result) << "Failed to flush.";
|
||||
// Don't flush the notifier here. Flushing here would write all the playlists
|
||||
// before all Media Playlists are read. Which could cause problems
|
||||
// setting the correct EXT-X-TARGETDURATION.
|
||||
}
|
||||
|
||||
void HlsNotifyMuxerListener::OnNewSegment(const std::string& file_name,
|
||||
|
|
|
@ -24,8 +24,16 @@ namespace media {
|
|||
class HlsNotifyMuxerListener : public MuxerListener {
|
||||
public:
|
||||
/// @param playlist_name is the name of the playlist for the muxer's stream.
|
||||
/// @param ext_x_media_name is the name of this playlist. This is the
|
||||
/// value of the NAME attribute for EXT-X-MEDIA, it is not the same as
|
||||
/// @a playlist_name. This may be empty for video.
|
||||
/// @param ext_x_media_group_id is the group ID for this playlist. This is the
|
||||
/// value of GROUP-ID attribute for EXT-X-MEDIA. This may be empty for
|
||||
/// video.
|
||||
/// @param hls_notifier used by this listener. Ownership does not transfer.
|
||||
HlsNotifyMuxerListener(const std::string& playlist_name,
|
||||
const std::string& ext_x_media_name,
|
||||
const std::string& ext_x_media_group_id,
|
||||
hls::HlsNotifier* hls_notifier);
|
||||
~HlsNotifyMuxerListener() override;
|
||||
|
||||
|
@ -58,6 +66,8 @@ class HlsNotifyMuxerListener : public MuxerListener {
|
|||
|
||||
private:
|
||||
const std::string playlist_name_;
|
||||
const std::string ext_x_media_name_;
|
||||
const std::string ext_x_media_group_id_;
|
||||
hls::HlsNotifier* const hls_notifier_;
|
||||
uint32_t stream_id_ = 0;
|
||||
|
||||
|
|
|
@ -66,13 +66,18 @@ const uint8_t kAnyData[] = {
|
|||
const bool kInitialEncryptionInfo = true;
|
||||
|
||||
const char kDefaultPlaylistName[] = "default_playlist.m3u8";
|
||||
const char kDefaultName[] = "DEFAULTNAME";
|
||||
const char kDefaultGroupId[] = "DEFAULTGROUPID";
|
||||
|
||||
} // namespace
|
||||
|
||||
class HlsNotifyMuxerListenerTest : public ::testing::Test {
|
||||
protected:
|
||||
HlsNotifyMuxerListenerTest()
|
||||
: listener_(kDefaultPlaylistName, &mock_notifier_) {}
|
||||
: listener_(kDefaultPlaylistName,
|
||||
kDefaultName,
|
||||
kDefaultGroupId,
|
||||
&mock_notifier_) {}
|
||||
|
||||
MockHlsNotifier mock_notifier_;
|
||||
HlsNotifyMuxerListener listener_;
|
||||
|
@ -100,29 +105,27 @@ TEST_F(HlsNotifyMuxerListenerTest, OnEncryptionInfoReady) {
|
|||
}
|
||||
|
||||
TEST_F(HlsNotifyMuxerListenerTest, OnMediaStart) {
|
||||
MuxerOptions muxer_options;
|
||||
muxer_options.hls_name = "Name";
|
||||
muxer_options.hls_group_id = "GroupID";
|
||||
SetDefaultMuxerOptionsValues(&muxer_options);
|
||||
VideoStreamInfoParameters video_params = GetDefaultVideoStreamInfoParams();
|
||||
scoped_refptr<StreamInfo> video_stream_info =
|
||||
CreateVideoStreamInfo(video_params);
|
||||
|
||||
EXPECT_CALL(mock_notifier_,
|
||||
NotifyNewStream(_, StrEq(kDefaultPlaylistName), StrEq("Name"),
|
||||
StrEq("GroupID"), _))
|
||||
NotifyNewStream(_, StrEq(kDefaultPlaylistName),
|
||||
StrEq("DEFAULTNAME"), StrEq("DEFAULTGROUPID"), _))
|
||||
.WillOnce(Return(true));
|
||||
|
||||
MuxerOptions muxer_options;
|
||||
listener_.OnMediaStart(muxer_options, *video_stream_info, 90000,
|
||||
MuxerListener::kContainerMpeg2ts);
|
||||
}
|
||||
|
||||
// Make sure it doesn't crash.
|
||||
TEST_F(HlsNotifyMuxerListenerTest, OnSampleDurationReady) {
|
||||
listener_.OnSampleDurationReady(2340);
|
||||
}
|
||||
|
||||
// Make sure it doesn't crash.
|
||||
TEST_F(HlsNotifyMuxerListenerTest, OnMediaEnd) {
|
||||
EXPECT_CALL(mock_notifier_, Flush()).WillOnce(Return(true));
|
||||
// None of these values matter, they are not used.
|
||||
listener_.OnMediaEnd(false, 0, 0, false, 0, 0, 0, 0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue