Use more data for creating VOD MediaInfo
MuxerListener takes MuxerOptions, reference time scale, and container type which should be passed to MediaInfo creation. Change-Id: I54c23476120e9ef77fc1df7e781b3a9acf0ff520
This commit is contained in:
parent
10ec2f0956
commit
172cd59987
|
@ -1,6 +1,7 @@
|
||||||
#include "media/event/vod_media_info_dump_muxer_listener.h"
|
#include "media/event/vod_media_info_dump_muxer_listener.h"
|
||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
|
#include "media/base/muxer_options.h"
|
||||||
#include "media/base/stream_info.h"
|
#include "media/base/stream_info.h"
|
||||||
#include "media/event/vod_muxer_listener_internal.h"
|
#include "media/event/vod_muxer_listener_internal.h"
|
||||||
#include "media/file/file.h"
|
#include "media/file/file.h"
|
||||||
|
@ -25,7 +26,9 @@ bool IsAnyStreamEncrypted(const std::vector<StreamInfo*>& stream_infos) {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
VodMediaInfoDumpMuxerListener::VodMediaInfoDumpMuxerListener(File* output_file)
|
VodMediaInfoDumpMuxerListener::VodMediaInfoDumpMuxerListener(File* output_file)
|
||||||
: file_(output_file) {}
|
: file_(output_file),
|
||||||
|
reference_time_scale_(0),
|
||||||
|
container_type_(kContainerUnknown) {}
|
||||||
|
|
||||||
VodMediaInfoDumpMuxerListener::~VodMediaInfoDumpMuxerListener() {}
|
VodMediaInfoDumpMuxerListener::~VodMediaInfoDumpMuxerListener() {}
|
||||||
|
|
||||||
|
@ -39,8 +42,9 @@ void VodMediaInfoDumpMuxerListener::OnMediaStart(
|
||||||
const std::vector<StreamInfo*>& stream_infos,
|
const std::vector<StreamInfo*>& stream_infos,
|
||||||
uint32 time_scale,
|
uint32 time_scale,
|
||||||
ContainerType container_type) {
|
ContainerType container_type) {
|
||||||
DLOG(INFO)
|
muxer_options_ = muxer_options;
|
||||||
<< "VodMediaInfoDumpMuxerListener does not care about OnMediaStart.";
|
reference_time_scale_ = time_scale;
|
||||||
|
container_type_ = container_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VodMediaInfoDumpMuxerListener::OnMediaEnd(
|
void VodMediaInfoDumpMuxerListener::OnMediaEnd(
|
||||||
|
@ -54,7 +58,8 @@ void VodMediaInfoDumpMuxerListener::OnMediaEnd(
|
||||||
float duration_seconds,
|
float duration_seconds,
|
||||||
uint64 file_size) {
|
uint64 file_size) {
|
||||||
MediaInfo media_info;
|
MediaInfo media_info;
|
||||||
if (!internal::GenerateMediaInfo(stream_infos,
|
if (!internal::GenerateMediaInfo(muxer_options_,
|
||||||
|
stream_infos,
|
||||||
has_init_range,
|
has_init_range,
|
||||||
init_range_start,
|
init_range_start,
|
||||||
init_range_end,
|
init_range_end,
|
||||||
|
@ -63,6 +68,8 @@ void VodMediaInfoDumpMuxerListener::OnMediaEnd(
|
||||||
index_range_end,
|
index_range_end,
|
||||||
duration_seconds,
|
duration_seconds,
|
||||||
file_size,
|
file_size,
|
||||||
|
reference_time_scale_,
|
||||||
|
container_type_,
|
||||||
&media_info)) {
|
&media_info)) {
|
||||||
LOG(ERROR) << "Failed to generate MediaInfo from input.";
|
LOG(ERROR) << "Failed to generate MediaInfo from input.";
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/compiler_specific.h"
|
#include "base/compiler_specific.h"
|
||||||
|
#include "media/base/muxer_options.h"
|
||||||
#include "media/event/muxer_listener.h"
|
#include "media/event/muxer_listener.h"
|
||||||
|
|
||||||
namespace dash_packager {
|
namespace dash_packager {
|
||||||
|
@ -17,7 +18,6 @@ class MediaInfo;
|
||||||
namespace media {
|
namespace media {
|
||||||
|
|
||||||
class File;
|
class File;
|
||||||
class MuxerOptions;
|
|
||||||
|
|
||||||
namespace event {
|
namespace event {
|
||||||
|
|
||||||
|
@ -58,6 +58,9 @@ class VodMediaInfoDumpMuxerListener : public MuxerListener {
|
||||||
|
|
||||||
File* file_;
|
File* file_;
|
||||||
std::string scheme_id_uri_;
|
std::string scheme_id_uri_;
|
||||||
|
MuxerOptions muxer_options_;
|
||||||
|
uint32 reference_time_scale_;
|
||||||
|
ContainerType container_type_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(VodMediaInfoDumpMuxerListener);
|
DISALLOW_COPY_AND_ASSIGN(VodMediaInfoDumpMuxerListener);
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,7 +14,9 @@ namespace event {
|
||||||
|
|
||||||
VodMpdNotifyMuxerListener::VodMpdNotifyMuxerListener(
|
VodMpdNotifyMuxerListener::VodMpdNotifyMuxerListener(
|
||||||
dash_packager::MpdNotifier* mpd_notifier)
|
dash_packager::MpdNotifier* mpd_notifier)
|
||||||
: mpd_notifier_(mpd_notifier) {
|
: mpd_notifier_(mpd_notifier),
|
||||||
|
reference_time_scale_(0),
|
||||||
|
container_type_(kContainerUnknown) {
|
||||||
DCHECK(mpd_notifier);
|
DCHECK(mpd_notifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +26,11 @@ void VodMpdNotifyMuxerListener::OnMediaStart(
|
||||||
const MuxerOptions& muxer_options,
|
const MuxerOptions& muxer_options,
|
||||||
const std::vector<StreamInfo*>& stream_infos,
|
const std::vector<StreamInfo*>& stream_infos,
|
||||||
uint32 time_scale,
|
uint32 time_scale,
|
||||||
ContainerType container_type) {}
|
ContainerType container_type) {
|
||||||
|
muxer_options_ = muxer_options;
|
||||||
|
reference_time_scale_ = time_scale;
|
||||||
|
container_type_ = container_type;
|
||||||
|
}
|
||||||
|
|
||||||
void VodMpdNotifyMuxerListener::OnMediaEnd(
|
void VodMpdNotifyMuxerListener::OnMediaEnd(
|
||||||
const std::vector<StreamInfo*>& stream_infos,
|
const std::vector<StreamInfo*>& stream_infos,
|
||||||
|
@ -37,7 +43,8 @@ void VodMpdNotifyMuxerListener::OnMediaEnd(
|
||||||
float duration_seconds,
|
float duration_seconds,
|
||||||
uint64 file_size) {
|
uint64 file_size) {
|
||||||
dash_packager::MediaInfo media_info;
|
dash_packager::MediaInfo media_info;
|
||||||
if (!internal::GenerateMediaInfo(stream_infos,
|
if (!internal::GenerateMediaInfo(muxer_options_,
|
||||||
|
stream_infos,
|
||||||
has_init_range,
|
has_init_range,
|
||||||
init_range_start,
|
init_range_start,
|
||||||
init_range_end,
|
init_range_end,
|
||||||
|
@ -46,6 +53,8 @@ void VodMpdNotifyMuxerListener::OnMediaEnd(
|
||||||
index_range_end,
|
index_range_end,
|
||||||
duration_seconds,
|
duration_seconds,
|
||||||
file_size,
|
file_size,
|
||||||
|
reference_time_scale_,
|
||||||
|
container_type_,
|
||||||
&media_info)) {
|
&media_info)) {
|
||||||
LOG(ERROR) << "Failed to generate MediaInfo from input.";
|
LOG(ERROR) << "Failed to generate MediaInfo from input.";
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/compiler_specific.h"
|
#include "base/compiler_specific.h"
|
||||||
|
#include "media/base/muxer_options.h"
|
||||||
#include "media/event/muxer_listener.h"
|
#include "media/event/muxer_listener.h"
|
||||||
|
|
||||||
namespace dash_packager {
|
namespace dash_packager {
|
||||||
|
@ -43,6 +44,9 @@ class VodMpdNotifyMuxerListener : public MuxerListener {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
dash_packager::MpdNotifier* const mpd_notifier_;
|
dash_packager::MpdNotifier* const mpd_notifier_;
|
||||||
|
MuxerOptions muxer_options_;
|
||||||
|
uint32 reference_time_scale_;
|
||||||
|
ContainerType container_type_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(VodMpdNotifyMuxerListener);
|
DISALLOW_COPY_AND_ASSIGN(VodMpdNotifyMuxerListener);
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "media/base/audio_stream_info.h"
|
#include "media/base/audio_stream_info.h"
|
||||||
|
#include "media/base/muxer_options.h"
|
||||||
#include "media/base/video_stream_info.h"
|
#include "media/base/video_stream_info.h"
|
||||||
#include "mpd/base/media_info.pb.h"
|
#include "mpd/base/media_info.pb.h"
|
||||||
#include "mpd/base/mpd_notifier.h"
|
#include "mpd/base/mpd_notifier.h"
|
||||||
|
@ -36,23 +37,13 @@ void SetRange(uint64 begin, uint64 end, Range* range) {
|
||||||
range->set_end(end);
|
range->set_end(end);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetMediaInfoCommonInfo(bool has_init_range,
|
void SetMediaInfoRanges(bool has_init_range,
|
||||||
uint64 init_range_start,
|
uint64 init_range_start,
|
||||||
uint64 init_range_end,
|
uint64 init_range_end,
|
||||||
bool has_index_range,
|
bool has_index_range,
|
||||||
uint64 index_range_start,
|
uint64 index_range_start,
|
||||||
uint64 index_range_end,
|
uint64 index_range_end,
|
||||||
float duration_seconds,
|
|
||||||
uint64 file_size,
|
|
||||||
MediaInfo* media_info) {
|
MediaInfo* media_info) {
|
||||||
DCHECK(media_info);
|
|
||||||
DCHECK_GT(file_size, 0);
|
|
||||||
DCHECK_GT(duration_seconds, 0.0f);
|
|
||||||
|
|
||||||
media_info->set_media_duration_seconds(duration_seconds);
|
|
||||||
media_info->set_bandwidth(
|
|
||||||
EstimateRequiredBandwidth(file_size, duration_seconds));
|
|
||||||
|
|
||||||
if (has_init_range) {
|
if (has_init_range) {
|
||||||
SetRange(
|
SetRange(
|
||||||
init_range_start, init_range_end, media_info->mutable_init_range());
|
init_range_start, init_range_end, media_info->mutable_init_range());
|
||||||
|
@ -64,6 +55,44 @@ void SetMediaInfoCommonInfo(bool has_init_range,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetMediaInfoContainerType(MuxerListener::ContainerType container_type,
|
||||||
|
MediaInfo* media_info) {
|
||||||
|
DCHECK(media_info);
|
||||||
|
switch (container_type) {
|
||||||
|
case MuxerListener::kContainerUnknown:
|
||||||
|
media_info->set_container_type(MediaInfo::CONTAINER_UNKNOWN);
|
||||||
|
break;
|
||||||
|
case MuxerListener::kContainerMp4:
|
||||||
|
media_info->set_container_type(MediaInfo::CONTAINER_MP4);
|
||||||
|
break;
|
||||||
|
case MuxerListener::kContainerMpeg2ts:
|
||||||
|
media_info->set_container_type(MediaInfo::CONTAINER_MPEG2_TS);
|
||||||
|
break;
|
||||||
|
case MuxerListener::kContainerWebM:
|
||||||
|
media_info->set_container_type(MediaInfo::CONTAINER_WEBM);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
NOTREACHED() << "Unknown container type " << container_type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetMediaInfoCommonInfo(float duration_seconds,
|
||||||
|
uint64 file_size,
|
||||||
|
uint32 reference_time_scale,
|
||||||
|
MuxerListener::ContainerType container_type,
|
||||||
|
MediaInfo* media_info) {
|
||||||
|
DCHECK(media_info);
|
||||||
|
DCHECK_GT(file_size, 0);
|
||||||
|
DCHECK_GT(duration_seconds, 0.0f);
|
||||||
|
|
||||||
|
media_info->set_media_duration_seconds(duration_seconds);
|
||||||
|
media_info->set_bandwidth(
|
||||||
|
EstimateRequiredBandwidth(file_size, duration_seconds));
|
||||||
|
|
||||||
|
media_info->set_reference_time_scale(reference_time_scale);
|
||||||
|
SetMediaInfoContainerType(container_type, media_info);
|
||||||
|
}
|
||||||
|
|
||||||
void AddVideoInfo(const VideoStreamInfo* video_stream_info,
|
void AddVideoInfo(const VideoStreamInfo* video_stream_info,
|
||||||
MediaInfo* media_info) {
|
MediaInfo* media_info) {
|
||||||
DCHECK(video_stream_info);
|
DCHECK(video_stream_info);
|
||||||
|
@ -124,9 +153,16 @@ void SetMediaInfoStreamInfo(const std::vector<StreamInfo*>& stream_infos,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetMediaInfoMuxerOptions(const MuxerOptions& muxer_options,
|
||||||
|
MediaInfo* media_info) {
|
||||||
|
DCHECK(media_info);
|
||||||
|
media_info->set_media_file_name(muxer_options.output_file_name);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
bool GenerateMediaInfo(const std::vector<StreamInfo*>& stream_infos,
|
bool GenerateMediaInfo(const MuxerOptions& muxer_options,
|
||||||
|
const std::vector<StreamInfo*>& stream_infos,
|
||||||
bool has_init_range,
|
bool has_init_range,
|
||||||
uint64 init_range_start,
|
uint64 init_range_start,
|
||||||
uint64 init_range_end,
|
uint64 init_range_end,
|
||||||
|
@ -135,10 +171,12 @@ bool GenerateMediaInfo(const std::vector<StreamInfo*>& stream_infos,
|
||||||
uint64 index_range_end,
|
uint64 index_range_end,
|
||||||
float duration_seconds,
|
float duration_seconds,
|
||||||
uint64 file_size,
|
uint64 file_size,
|
||||||
|
uint32 reference_time_scale,
|
||||||
|
MuxerListener::ContainerType container_type,
|
||||||
MediaInfo* media_info) {
|
MediaInfo* media_info) {
|
||||||
DCHECK(media_info);
|
DCHECK(media_info);
|
||||||
if (file_size == 0) {
|
if (file_size == 0) {
|
||||||
// TODO(rkurowia); bandwidth is a required field for MPD. But without the
|
// TODO(rkuroiwa): bandwidth is a required field for MPD. But without the
|
||||||
// file size, AFAIK there's not much I can do. Fail silently?
|
// file size, AFAIK there's not much I can do. Fail silently?
|
||||||
LOG(ERROR) << "File size not specified.";
|
LOG(ERROR) << "File size not specified.";
|
||||||
return false;
|
return false;
|
||||||
|
@ -150,14 +188,18 @@ bool GenerateMediaInfo(const std::vector<StreamInfo*>& stream_infos,
|
||||||
return false;;
|
return false;;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetMediaInfoCommonInfo(has_init_range,
|
SetMediaInfoMuxerOptions(muxer_options, media_info);
|
||||||
|
SetMediaInfoRanges(has_init_range,
|
||||||
init_range_start,
|
init_range_start,
|
||||||
init_range_end,
|
init_range_end,
|
||||||
has_index_range,
|
has_index_range,
|
||||||
index_range_start,
|
index_range_start,
|
||||||
index_range_end,
|
index_range_end,
|
||||||
duration_seconds,
|
media_info);
|
||||||
|
SetMediaInfoCommonInfo(duration_seconds,
|
||||||
file_size,
|
file_size,
|
||||||
|
reference_time_scale,
|
||||||
|
container_type,
|
||||||
media_info);
|
media_info);
|
||||||
SetMediaInfoStreamInfo(stream_infos, media_info);
|
SetMediaInfoStreamInfo(stream_infos, media_info);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/basictypes.h"
|
#include "base/basictypes.h"
|
||||||
|
#include "media/event/muxer_listener.h"
|
||||||
|
|
||||||
namespace dash_packager {
|
namespace dash_packager {
|
||||||
class MediaInfo;
|
class MediaInfo;
|
||||||
|
@ -11,6 +12,7 @@ class MediaInfo;
|
||||||
|
|
||||||
namespace media {
|
namespace media {
|
||||||
|
|
||||||
|
class MuxerOptions;
|
||||||
class StreamInfo;
|
class StreamInfo;
|
||||||
|
|
||||||
namespace event {
|
namespace event {
|
||||||
|
@ -18,7 +20,8 @@ namespace internal {
|
||||||
|
|
||||||
// On success fill |media_info| with input data and return true, otherwise
|
// On success fill |media_info| with input data and return true, otherwise
|
||||||
// return false.
|
// return false.
|
||||||
bool GenerateMediaInfo(const std::vector<StreamInfo*>& stream_infos,
|
bool GenerateMediaInfo(const MuxerOptions& muxer_options,
|
||||||
|
const std::vector<StreamInfo*>& stream_infos,
|
||||||
bool has_init_range,
|
bool has_init_range,
|
||||||
uint64 init_range_start,
|
uint64 init_range_start,
|
||||||
uint64 init_range_end,
|
uint64 init_range_end,
|
||||||
|
@ -27,6 +30,8 @@ bool GenerateMediaInfo(const std::vector<StreamInfo*>& stream_infos,
|
||||||
uint64 index_range_end,
|
uint64 index_range_end,
|
||||||
float duration_seconds,
|
float duration_seconds,
|
||||||
uint64 file_size,
|
uint64 file_size,
|
||||||
|
uint32 reference_time_scale_,
|
||||||
|
MuxerListener::ContainerType container_type,
|
||||||
dash_packager::MediaInfo* media_info);
|
dash_packager::MediaInfo* media_info);
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
Loading…
Reference in New Issue